mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-17 11:03:36 +08:00
Constraints on regular PostgreSQL tables need to be validatated so that they don't have a foreign key constraint that references a hypertable, as this is not yet supported. This change fixes a bug in this validation caused by not checking for the proper node types when parsing a CreateStmt node. The CreateStmt is now also parsed in the DDL end hook, instead of the processUtility hook, which ensures that the CreateStmt node has been run through parse analysis. The parse analysis changes the contents of the node to be more consistent across different CREATE statements. For instance, a CREATE LIKE statement will look more similar to a regular CREATE statement after parse analysis.
14 lines
503 B
SQL
14 lines
503 B
SQL
\ir include/create_single_db.sql
|
|
|
|
-- Test that we can verify constraints on regular tables
|
|
CREATE TABLE test_hyper_pk(time TIMESTAMPTZ PRIMARY KEY, temp FLOAT, device INT);
|
|
CREATE TABLE test_pk(device INT PRIMARY KEY);
|
|
CREATE TABLE test_like(LIKE test_pk);
|
|
|
|
SELECT create_hypertable('test_hyper_pk', 'time');
|
|
|
|
\set ON_ERROR_STOP 0
|
|
-- Foreign key constraints that reference hypertables are currently unsupported
|
|
CREATE TABLE test_fk(time TIMESTAMPTZ REFERENCES test_hyper_pk(time));
|
|
\set ON_ERROR_STOP 1
|