-
Notifications
You must be signed in to change notification settings - Fork 670
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update update . move the tests update update update style
- Loading branch information
Showing
6 changed files
with
271 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
-- | ||
-- PG17 | ||
-- | ||
CREATE SCHEMA pg17; | ||
SET search_path TO pg17; | ||
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 | ||
--------------------------------------------------------------------- | ||
|
||
(1 row) | ||
|
||
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 | ||
--------------------------------------------------------------------- | ||
|
||
(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 =); | ||
-- 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: 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 | ||
--------------------------------------------------------------------- | ||
citus_local_partitioned_table_check | ||
citus_local_partitioned_table_partition_col_excl | ||
(2 rows) | ||
|
||
\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 | ||
longlonglonglonglonglonglonglonglonglonglong_partition_col_excl | ||
(2 rows) | ||
|
||
\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 | ||
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 | ||
--------------------------------------------------------------------- | ||
longlonglonglonglonglonglonglonglonglonglong_partition_col_excl | ||
(1 row) | ||
|
||
-- Clean up | ||
\set VERBOSITY terse | ||
SET client_min_messages TO ERROR; | ||
DROP SCHEMA pg17 CASCADE; | ||
ERROR: operation is not allowed on this node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
-- | ||
-- PG17 | ||
-- | ||
CREATE SCHEMA pg17; | ||
SET search_path TO pg17; | ||
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 | ||
--------------------------------------------------------------------- | ||
|
||
(1 row) | ||
|
||
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 | ||
--------------------------------------------------------------------- | ||
|
||
(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: 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 | ||
--------------------------------------------------------------------- | ||
citus_local_partitioned_table_check | ||
(1 row) | ||
|
||
\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 | ||
(1 row) | ||
|
||
\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 | ||
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 | ||
--------------------------------------------------------------------- | ||
(0 rows) | ||
|
||
-- Clean up | ||
\set VERBOSITY terse | ||
SET client_min_messages TO ERROR; | ||
DROP SCHEMA pg17 CASCADE; | ||
ERROR: operation is not allowed on this node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
-- | ||
-- PG17 | ||
-- | ||
CREATE SCHEMA pg17; | ||
SET search_path TO pg17; | ||
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'); | ||
|
||
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'; | ||
|
||
-- 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'); | ||
|
||
\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 =); | ||
|
||
-- Check "ADD CHECK" | ||
SET client_min_messages TO DEBUG1; | ||
ALTER TABLE AT_AddConstNoName.citus_local_partitioned_table ADD CHECK (dist_col > 0); | ||
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'; | ||
|
||
\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; | ||
|
||
\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 | ||
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; | ||
|
||
-- Clean up | ||
\set VERBOSITY terse | ||
SET client_min_messages TO ERROR; | ||
DROP SCHEMA pg17 CASCADE; |