Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
m3hm3t committed Nov 15, 2024
1 parent 4d71c05 commit 291b9ae
Showing 1 changed file with 67 additions and 43 deletions.
110 changes: 67 additions & 43 deletions src/test/regress/expected/pg17_0.out
Original file line number Diff line number Diff line change
Expand Up @@ -7,67 +7,91 @@ SET citus.next_shard_id TO 917000;
ALTER SEQUENCE pg_catalog.pg_dist_colocationid_seq RESTART 1400000;
SET citus.shard_count TO 1;
SET citus.shard_replication_factor TO 1;
-- PostgreSQL 17 now allows exclusion constraints on partitioned tables, lifting the previous restriction.
ALTER SEQUENCE pg_catalog.pg_dist_shardid_seq RESTART 5420000;
ALTER SEQUENCE pg_catalog.pg_dist_placement_placementid_seq RESTART 5420000;
CREATE SCHEMA AT_AddConstNoName;
-- Check "ADD PRIMARY KEY"
CREATE TABLE AT_AddConstNoName.products (
product_no integer,
name text,
price numeric
);
SELECT create_distributed_table('AT_AddConstNoName.products', 'product_no');
create_distributed_table
---------------------------------------------------------------------

--- PostgreSQL 17 now allows exclusion constraints on partitioned tables, lifting the previous restriction.
\c :master_host :master_port
ALTER TABLE AT_AddConstNoName.citus_local_partitioned_table DROP CONSTRAINT citus_local_partitioned_table_partition_col_key;
(1 row)

--- Check "ADD EXCLUDE" errors out for partitioned table since the postgres does not allow it before PG 17
ALTER TABLE AT_AddConstNoName.citus_local_partitioned_table ADD EXCLUDE(partition_col WITH =);
ERROR: exclusion constraints are not supported on partitioned tables
ALTER TABLE AT_AddConstNoName.products ADD PRIMARY KEY(product_no);
SELECT con.conname
FROM pg_catalog.pg_constraint con
INNER JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
INNER JOIN pg_catalog.pg_namespace nsp ON nsp.oid = connamespace
WHERE rel.relname = 'products';
conname
---------------------------------------------------------------------
products_pkey
(1 row)

-- Test with partitioned citus local table
CREATE TABLE AT_AddConstNoName.citus_local_partitioned_table (dist_col int, another_col int, partition_col timestamp) PARTITION BY RANGE (partition_col);
CREATE TABLE AT_AddConstNoName.p1 PARTITION OF AT_AddConstNoName.citus_local_partitioned_table FOR VALUES FROM ('2021-01-01') TO ('2022-01-01');
CREATE TABLE AT_AddConstNoName.longlonglonglonglonglonglonglonglonglonglonglonglonglonglongabc PARTITION OF AT_AddConstNoName.citus_local_partitioned_table FOR VALUES FROM ('2020-01-01') TO ('2021-01-01');
SELECT citus_add_local_table_to_metadata('AT_AddConstNoName.citus_local_partitioned_table');
citus_add_local_table_to_metadata
---------------------------------------------------------------------

--- Check "ADD CHECK"
(1 row)

\c - - :master_host :master_port
-- Check "ADD EXCLUDE" errors out for partitioned table since the postgres does not allow it before PG 17
ALTER TABLE AT_AddConstNoName.citus_local_partitioned_table ADD EXCLUDE(partition_col WITH =);
ERROR: exclusion constraints are not supported on partitioned tables
-- Check "ADD CHECK"
SET client_min_messages TO DEBUG1;
ALTER TABLE AT_AddConstNoName.citus_local_partitioned_table ADD CHECK (dist_col > 0);
DEBUG: the constraint name on the shards of the partition is too long, switching to sequential and local execution mode to prevent self deadlocks: longlonglonglonglonglonglonglonglonglonglonglo_537570f5_5_check
DEBUG: verifying table "longlonglonglonglonglonglonglonglonglonglonglonglonglonglongabc"
DEBUG: verifying table "p1"
DEBUG: the constraint name on the shards of the partition is too long, switching to sequential and local execution mode to prevent self deadlocks: longlonglonglonglonglonglonglonglonglonglonglon_537570f5__check
DEBUG: verifying table "longlonglonglonglonglonglonglonglonglonglonglonglonglonglongabc"
DEBUG: verifying table "p1"
DEBUG: verifying table "p1_917002"
DEBUG: verifying table "longlonglonglonglonglonglonglonglonglonglonglon_537570f5_917001"
RESET client_min_messages;

SELECT con.conname
FROM pg_catalog.pg_constraint con
INNER JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
INNER JOIN pg_catalog.pg_namespace nsp ON nsp.oid = connamespace
WHERE rel.relname = 'citus_local_partitioned_table';
conname
----------------------------------------------------------------------
FROM pg_catalog.pg_constraint con
INNER JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
INNER JOIN pg_catalog.pg_namespace nsp ON nsp.oid = connamespace
WHERE rel.relname = 'citus_local_partitioned_table';
conname
---------------------------------------------------------------------
citus_local_partitioned_table_check
(1 row)

\c :public_worker_1_host :worker_1_port

\c - - :public_worker_1_host :worker_1_port
SELECT con.conname
FROM pg_catalog.pg_constraint con
INNER JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
INNER JOIN pg_catalog.pg_namespace nsp ON nsp.oid = connamespace
WHERE rel.relname LIKE 'longlonglonglonglonglonglonglonglong%'
ORDER BY con.conname ASC;
conname
----------------------------------------------------------------------
citus_local_partitioned_table_check
citus_local_partitioned_table_check
citus_local_partitioned_table_check
FROM pg_catalog.pg_constraint con
INNER JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
INNER JOIN pg_catalog.pg_namespace nsp ON nsp.oid = connamespace
WHERE rel.relname LIKE 'longlonglonglonglonglonglonglonglong%' ORDER BY con.conname ASC;
conname
---------------------------------------------------------------------
citus_local_partitioned_table_check
citus_local_partitioned_table_check
(5 rows)
(1 row)

\c :master_host :master_port
\c - - :master_host :master_port
ALTER TABLE AT_AddConstNoName.citus_local_partitioned_table DROP CONSTRAINT citus_local_partitioned_table_check;

\c :public_worker_1_host :worker_1_port

\c - - :public_worker_1_host :worker_1_port
SELECT con.conname
FROM pg_catalog.pg_constraint con
INNER JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
INNER JOIN pg_catalog.pg_namespace nsp ON nsp.oid = connamespace
WHERE rel.relname LIKE 'longlonglonglonglonglonglonglonglong%'
ORDER BY con.conname ASC;
FROM pg_catalog.pg_constraint con
INNER JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
INNER JOIN pg_catalog.pg_namespace nsp ON nsp.oid = connamespace
WHERE rel.relname LIKE 'longlonglonglonglonglonglonglonglong%' ORDER BY con.conname ASC;
conname
----------------------------------------------------------------------
---------------------------------------------------------------------
(0 rows)

--- Clean up
-- Clean up
\set VERBOSITY terse
SET client_min_messages TO ERROR;
DROP SCHEMA pg17 CASCADE;
ERROR: operation is not allowed on this node
ERROR: operation is not allowed on this node

0 comments on commit 291b9ae

Please sign in to comment.