From 3e272135b1f58cd7a050abc7d4fce86b09528756 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Wed, 29 Apr 2026 09:42:10 +0000 Subject: [PATCH v5 2/2] Simplify error comments in partition split/merge tests The partition split/merge regression tests copy the full error, detail, and hint text into SQL comments above each failing statement. These comments duplicate the actual server output and have to be updated whenever the wording changes. Replace those copied messages with a short -- ERROR marker so future wording changes only need to update the expected output. Keep the descriptive comments that explain each scenario. --- src/test/regress/expected/partition_merge.out | 44 +++++------ src/test/regress/expected/partition_split.out | 78 +++++++++---------- src/test/regress/sql/partition_merge.sql | 44 +++++------ src/test/regress/sql/partition_split.sql | 78 +++++++++---------- 4 files changed, 112 insertions(+), 132 deletions(-) diff --git a/src/test/regress/expected/partition_merge.out b/src/test/regress/expected/partition_merge.out index d941046eb28..68733698429 100644 --- a/src/test/regress/expected/partition_merge.out +++ b/src/test/regress/expected/partition_merge.out @@ -21,35 +21,33 @@ CREATE TABLE sales_apr_1 PARTITION OF sales_apr2022 FOR VALUES FROM ('2022-04-01 CREATE TABLE sales_apr_2 PARTITION OF sales_apr2022 FOR VALUES FROM ('2022-04-15') TO ('2022-05-01'); ALTER TABLE sales_range ATTACH PARTITION sales_apr2022 FOR VALUES FROM ('2022-04-01') TO ('2022-05-01'); CREATE TABLE sales_others PARTITION OF sales_range DEFAULT; --- ERROR: partition with name "sales_feb2022" is already used +-- ERROR ALTER TABLE sales_range MERGE PARTITIONS (sales_feb2022, sales_mar2022, sales_feb2022) INTO sales_feb_mar_apr2022; ERROR: partition with name "sales_feb2022" is already used LINE 1: ...e MERGE PARTITIONS (sales_feb2022, sales_mar2022, sales_feb2... ^ --- ERROR: "sales_apr2022" is not a table +-- ERROR ALTER TABLE sales_range MERGE PARTITIONS (sales_feb2022, sales_mar2022, sales_apr2022) INTO sales_feb_mar_apr2022; ERROR: "sales_apr2022" is not a table HINT: ALTER TABLE ... MERGE PARTITIONS can only merge partitions don't have sub-partitions. --- ERROR: can not merge partition "sales_mar2022" together with partition "sales_jan2022" --- DETAIL: lower bound of partition "sales_mar2022" is not equal to the upper bound of partition "sales_jan2022" +-- ERROR -- (space between sections sales_jan2022 and sales_mar2022) ALTER TABLE sales_range MERGE PARTITIONS (sales_jan2022, sales_mar2022) INTO sales_jan_mar2022; ERROR: cannot merge partition "sales_mar2022" together with partition "sales_jan2022" DETAIL: The lower bound of partition "sales_mar2022" is not equal to the upper bound of partition "sales_jan2022". HINT: ALTER TABLE ... MERGE PARTITIONS requires the old partition bounds to be adjacent. --- ERROR: can not merge partition "sales_jan2022" together with partition "sales_dec2021" --- DETAIL: lower bound of partition "sales_jan2022" is not equal to the upper bound of partition "sales_dec2021" +-- ERROR -- (space between sections sales_dec2021 and sales_jan2022) ALTER TABLE sales_range MERGE PARTITIONS (sales_dec2021, sales_jan2022, sales_feb2022) INTO sales_dec_jan_feb2022; ERROR: cannot merge partition "sales_jan2022" together with partition "sales_dec2021" DETAIL: The lower bound of partition "sales_jan2022" is not equal to the upper bound of partition "sales_dec2021". HINT: ALTER TABLE ... MERGE PARTITIONS requires the old partition bounds to be adjacent. --- ERROR: partition with name "sales_feb2022" is already used +-- ERROR ALTER TABLE sales_range MERGE PARTITIONS (sales_feb2022, sales_mar2022, partitions_merge_schema.sales_feb2022) INTO sales_feb_mar_apr2022; ERROR: partition with name "sales_feb2022" is already used LINE 1: ...e MERGE PARTITIONS (sales_feb2022, sales_mar2022, partitions... ^ ---ERROR, sales_apr_2 already exists +-- ERROR ALTER TABLE sales_range MERGE PARTITIONS (sales_feb2022, sales_mar2022, sales_jan2022) INTO sales_apr_2; ERROR: relation "sales_apr_2" already exists CREATE VIEW jan2022v as SELECT * FROM sales_jan2022; @@ -480,15 +478,15 @@ CREATE TABLE sales_nord2 PARTITION OF sales_list2 FOR VALUES IN ('Oslo', 'St. Pe CREATE TABLE sales_others2 PARTITION OF sales_list2 DEFAULT; CREATE TABLE sales_external (LIKE sales_list); CREATE TABLE sales_external2 (vch VARCHAR(5)); --- ERROR: "sales_external" is not a partition of partitioned table "sales_list" +-- ERROR ALTER TABLE sales_list MERGE PARTITIONS (sales_west, sales_east, sales_external) INTO sales_all; ERROR: "sales_external" is not a partition of partitioned table "sales_list" HINT: ALTER TABLE ... MERGE PARTITIONS can only merge partitions don't have sub-partitions. --- ERROR: "sales_external2" is not a partition of partitioned table "sales_list" +-- ERROR ALTER TABLE sales_list MERGE PARTITIONS (sales_west, sales_east, sales_external2) INTO sales_all; ERROR: "sales_external2" is not a partition of partitioned table "sales_list" HINT: ALTER TABLE ... MERGE PARTITIONS can only merge partitions don't have sub-partitions. --- ERROR: relation "sales_nord2" is not a partition of relation "sales_list" +-- ERROR ALTER TABLE sales_list MERGE PARTITIONS (sales_west, sales_nord2, sales_east) INTO sales_all; ERROR: relation "sales_nord2" is not a partition of relation "sales_list" HINT: ALTER TABLE ... MERGE PARTITIONS can only merge partitions don't have sub-partitions. @@ -630,11 +628,11 @@ CREATE TABLE t1p1 PARTITION OF t1 FOR VALUES FROM (1, 1) TO (1, 2); CREATE TABLE t2 (i int, t text) PARTITION BY RANGE (t); CREATE TABLE t2pa PARTITION OF t2 FOR VALUES FROM ('A') TO ('C'); CREATE TABLE t3 (i int, t text); --- ERROR: relation "t1p1" is not a partition of relation "t2" +-- ERROR ALTER TABLE t2 MERGE PARTITIONS (t1p1, t2pa) INTO t2p; ERROR: relation "t1p1" is not a partition of relation "t2" HINT: ALTER TABLE ... MERGE PARTITIONS can only merge partitions don't have sub-partitions. --- ERROR: "t3" is not a partition of partitioned table "t2" +-- ERROR ALTER TABLE t2 MERGE PARTITIONS (t2pa, t3) INTO t2p; ERROR: "t3" is not a partition of partitioned table "t2" HINT: ALTER TABLE ... MERGE PARTITIONS can only merge partitions don't have sub-partitions. @@ -690,7 +688,7 @@ EXECUTE get_partition_info('{t}'); tp_3_4 | t | r | f | FOR VALUES FROM (3) TO (4) (2 rows) --- ERROR: cannot create a permanent relation as partition of temporary relation "t" +-- ERROR ALTER TABLE t MERGE PARTITIONS (tp_0_3, tp_3_4) INTO tp_0_4; ERROR: cannot create a permanent relation as partition of temporary relation "t" ROLLBACK; @@ -806,19 +804,19 @@ CREATE TABLE t (i int) PARTITION BY RANGE (i); CREATE TABLE tp_0_1 PARTITION OF t FOR VALUES FROM (0) TO (1); CREATE TABLE tp_1_2 PARTITION OF t FOR VALUES FROM (1) TO (2); SET SESSION AUTHORIZATION regress_partition_merge_bob; --- ERROR: must be owner of table t +-- ERROR ALTER TABLE t MERGE PARTITIONS (tp_0_1, tp_1_2) INTO tp_0_2; ERROR: must be owner of table t RESET SESSION AUTHORIZATION; ALTER TABLE t OWNER TO regress_partition_merge_bob; SET SESSION AUTHORIZATION regress_partition_merge_bob; --- ERROR: must be owner of table tp_0_1 +-- ERROR ALTER TABLE t MERGE PARTITIONS (tp_0_1, tp_1_2) INTO tp_0_2; ERROR: must be owner of table tp_0_1 RESET SESSION AUTHORIZATION; ALTER TABLE tp_0_1 OWNER TO regress_partition_merge_bob; SET SESSION AUTHORIZATION regress_partition_merge_bob; --- ERROR: must be owner of table tp_1_2 +-- ERROR ALTER TABLE t MERGE PARTITIONS (tp_0_1, tp_1_2) INTO tp_0_2; ERROR: must be owner of table tp_1_2 RESET SESSION AUTHORIZATION; @@ -852,7 +850,7 @@ ALTER TABLE t ATTACH PARTITION tp_1_2 FOR VALUES FROM (1) TO (2); partitions_merge_schema | tp_1_2 | table | regress_partition_merge_bob (1 row) --- ERROR: partitions being merged have different owners +-- ERROR ALTER TABLE t MERGE PARTITIONS (tp_0_1, tp_1_2) INTO tp_0_2; ERROR: partitions being merged have different owners DROP TABLE t; @@ -864,10 +862,10 @@ DROP ROLE regress_partition_merge_bob; CREATE TABLE t (i int) PARTITION BY HASH(i); CREATE TABLE tp1 PARTITION OF t FOR VALUES WITH (MODULUS 2, REMAINDER 0); CREATE TABLE tp2 PARTITION OF t FOR VALUES WITH (MODULUS 2, REMAINDER 1); --- ERROR: partition of hash-partitioned table cannot be merged +-- ERROR ALTER TABLE t MERGE PARTITIONS (tp1, tp2) INTO tp3; ERROR: partition of hash-partitioned table cannot be merged --- ERROR: list of partitions to be merged should include at least two partitions +-- ERROR ALTER TABLE t MERGE PARTITIONS (tp1) INTO tp3; ERROR: list of partitions to be merged should include at least two partitions DROP TABLE t; @@ -999,7 +997,7 @@ Indexes: Referenced by: TABLE "t_fk" CONSTRAINT "t_fk_i_fkey" FOREIGN KEY (i) REFERENCES t(i) NOT VALID --- ERROR: insert or update on table "t_fk" violates foreign key constraint "t_fk_i_fkey" +-- ERROR ALTER TABLE t_fk VALIDATE CONSTRAINT t_fk_i_fkey; ERROR: insert or update on table "t_fk" violates foreign key constraint "t_fk_i_fkey" DETAIL: Key (i)=(2) is not present in table "t". @@ -1026,7 +1024,7 @@ Indexes: Referenced by: TABLE "t_fk" CONSTRAINT "t_fk_i_fkey" FOREIGN KEY (i) REFERENCES t(i) NOT ENFORCED --- ERROR: insert or update on table "t_fk" violates foreign key constraint "t_fk_i_fkey" +-- ERROR ALTER TABLE t_fk ALTER CONSTRAINT t_fk_i_fkey ENFORCED; ERROR: insert or update on table "t_fk" violates foreign key constraint "t_fk_i_fkey" DETAIL: Key (i)=(2) is not present in table "t". @@ -1070,7 +1068,7 @@ ALTER TABLE t ADD CHECK (i > 0); INSERT INTO t VALUES (5), (15); ALTER TABLE t MERGE PARTITIONS (tp_1, tp_2) INTO tp_12; INSERT INTO t VALUES (16); --- ERROR: new row for relation "tp_12" violates check constraint "t_i_check" +-- ERROR INSERT INTO t VALUES (0); ERROR: new row for relation "tp_12" violates check constraint "t_i_check" DETAIL: Failing row contains (0, virtual). diff --git a/src/test/regress/expected/partition_split.out b/src/test/regress/expected/partition_split.out index d00c0cc074e..affcc019923 100644 --- a/src/test/regress/expected/partition_split.out +++ b/src/test/regress/expected/partition_split.out @@ -15,19 +15,19 @@ CREATE TABLE sales_range (salesperson_id int, sales_date date) PARTITION BY RANG CREATE TABLE sales_jan2022 PARTITION OF sales_range FOR VALUES FROM ('2022-01-01') TO ('2022-02-01'); CREATE TABLE sales_feb_mar_apr2022 PARTITION OF sales_range FOR VALUES FROM ('2022-02-01') TO ('2022-05-01'); CREATE TABLE sales_others PARTITION OF sales_range DEFAULT; --- ERROR: relation "sales_xxx" does not exist +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_xxx INTO (PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'), PARTITION sales_mar2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'), PARTITION sales_apr2022 FOR VALUES FROM ('2022-04-01') TO ('2022-05-01')); ERROR: relation "sales_xxx" does not exist --- ERROR: relation "sales_jan2022" already exists +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_jan2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'), PARTITION sales_mar2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'), PARTITION sales_apr2022 FOR VALUES FROM ('2022-04-01') TO ('2022-05-01')); ERROR: relation "sales_jan2022" already exists --- ERROR: invalid bound specification for a range partition +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_jan2022 FOR VALUES IN ('2022-05-01', '2022-06-01'), PARTITION sales_mar2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'), @@ -35,7 +35,7 @@ ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO ERROR: invalid bound specification for a range partition LINE 2: (PARTITION sales_jan2022 FOR VALUES IN ('2022-05-01', '202... ^ --- ERROR: empty range bound specified for partition "sales_mar2022" +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'), PARTITION sales_mar2022 FOR VALUES FROM ('2022-03-01') TO ('2022-02-01'), @@ -44,12 +44,11 @@ ERROR: empty range bound specified for partition "sales_mar2022" LINE 3: PARTITION sales_mar2022 FOR VALUES FROM ('2022-03-01') TO... ^ DETAIL: Specified lower bound ('03-01-2022') is greater than or equal to upper bound ('02-01-2022'). ---ERROR: list of split partitions should contain at least two items +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-01') TO ('2022-10-01')); ERROR: list of new partitions should contain at least two partitions --- ERROR: lower bound of partition "sales_feb2022" is not equal to lower bound of split partition "sales_feb_mar_apr2022" --- HINT: ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition. +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_feb2022 FOR VALUES FROM ('2022-01-01') TO ('2022-03-01'), PARTITION sales_mar2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'), @@ -58,7 +57,7 @@ ERROR: lower bound of partition "sales_feb2022" is not equal to lower bound of LINE 2: (PARTITION sales_feb2022 FOR VALUES FROM ('2022-01-01') TO... ^ HINT: ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition. --- ERROR: partition with name "sales_feb_mar_apr2022" is already used +-- ERROR -- (We can create partition with the same name as split partition, but can't create two partitions with the same name) ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_feb_mar_apr2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'), @@ -67,7 +66,7 @@ ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO ERROR: partition with name "sales_feb_mar_apr2022" is already used LINE 3: PARTITION sales_feb_mar_apr2022 FOR VALUES FROM ('2022-03... ^ --- ERROR: partition with name "sales_feb2022" is already used +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'), PARTITION sales_feb2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'), @@ -75,7 +74,7 @@ ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO ERROR: partition with name "sales_feb2022" is already used LINE 3: PARTITION sales_feb2022 FOR VALUES FROM ('2022-03-01') TO... ^ --- ERROR: partition with name "sales_feb2022" is already used +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'), PARTITION partition_split_schema.sales_feb2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'), @@ -83,16 +82,14 @@ ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO ERROR: partition with name "sales_feb2022" is already used LINE 3: PARTITION partition_split_schema.sales_feb2022 FOR VALUES... ^ --- ERROR: ALTER action SPLIT PARTITION cannot be performed on relation "sales_feb_mar_apr2022" --- DETAIL: This operation is not supported for tables. +-- ERROR ALTER TABLE sales_feb_mar_apr2022 SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_jan2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'), PARTITION sales_feb2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'), PARTITION sales_apr2022 FOR VALUES FROM ('2022-04-01') TO ('2022-05-01')); ERROR: ALTER action SPLIT PARTITION cannot be performed on relation "sales_feb_mar_apr2022" DETAIL: This operation is not supported for tables. --- ERROR: upper bound of partition "sales_apr2022" is not equal to upper bound of split partition "sales_feb_mar_apr2022" --- HINT: ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition. +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'), PARTITION sales_mar2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'), @@ -101,7 +98,7 @@ ERROR: upper bound of partition "sales_apr2022" is not equal to upper bound of LINE 4: ... sales_apr2022 FOR VALUES FROM ('2022-04-01') TO ('2022-06-0... ^ HINT: ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition. --- ERROR: can not split to partition "sales_mar2022" together with partition "sales_feb2022" +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'), PARTITION sales_mar2022 FOR VALUES FROM ('2022-02-01') TO ('2022-04-01'), @@ -113,8 +110,7 @@ DETAIL: The lower bound of partition "sales_mar2022" is not equal to the upper HINT: ALTER TABLE ... SPLIT PARTITION requires the new partition bounds to be adjacent. -- Tests for spaces between partitions, them should be executed without DEFAULT partition ALTER TABLE sales_range DETACH PARTITION sales_others; --- ERROR: lower bound of partition "sales_feb2022" is not equal to lower bound of split partition "sales_feb_mar_apr2022" --- HINT: ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition. +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-02') TO ('2022-03-01'), PARTITION sales_mar2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'), @@ -150,8 +146,7 @@ DROP TABLE sales_others; CREATE TABLE sales_range (sales_date date) PARTITION BY RANGE (sales_date); CREATE TABLE sales_jan2022 PARTITION OF sales_range FOR VALUES FROM ('2022-01-01') TO ('2022-02-01'); CREATE TABLE sales_feb_mar_apr2022 PARTITION OF sales_range FOR VALUES FROM ('2022-02-01') TO ('2022-05-01'); --- ERROR: upper bound of partition "sales_apr2022" is not equal to upper bound of split partition "sales_feb_mar_apr2022" --- HINT: ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition. +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'), PARTITION sales_mar2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'), @@ -461,7 +456,7 @@ DROP TABLE sales_range CASCADE; CREATE TABLE sales_range (salesperson_id INT, sales_date date) PARTITION BY RANGE (sales_date); CREATE TABLE sales_others PARTITION OF sales_range DEFAULT; -- sales_error intersects with sales_dec2021 (lower bound) --- ERROR: can not split to partition "sales_error" together with partition "sales_dec2021" +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_others INTO (PARTITION sales_dec2021 FOR VALUES FROM ('2021-12-01') TO ('2022-01-01'), PARTITION sales_error FOR VALUES FROM ('2021-12-30') TO ('2022-02-01'), @@ -473,7 +468,7 @@ LINE 3: PARTITION sales_error FOR VALUES FROM ('2021-12-30') TO (... DETAIL: The lower bound of partition "sales_error" is not equal to the upper bound of partition "sales_dec2021". HINT: ALTER TABLE ... SPLIT PARTITION requires the new partition bounds to be adjacent. -- sales_error intersects with sales_feb2022 (upper bound) --- ERROR: can not split to partition "sales_feb2022" together with partition "sales_error" +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_others INTO (PARTITION sales_dec2021 FOR VALUES FROM ('2021-12-01') TO ('2022-01-01'), PARTITION sales_error FOR VALUES FROM ('2022-01-01') TO ('2022-02-02'), @@ -485,7 +480,7 @@ LINE 4: PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-01') TO... DETAIL: The lower bound of partition "sales_feb2022" is not equal to the upper bound of partition "sales_error". HINT: ALTER TABLE ... SPLIT PARTITION requires the new partition bounds to be adjacent. -- sales_error intersects with sales_dec2021 (inside bound) --- ERROR: can not split to partition "sales_error" together with partition "sales_dec2021" +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_others INTO (PARTITION sales_dec2021 FOR VALUES FROM ('2021-12-01') TO ('2022-01-01'), PARTITION sales_error FOR VALUES FROM ('2021-12-10') TO ('2021-12-20'), @@ -497,7 +492,7 @@ LINE 3: PARTITION sales_error FOR VALUES FROM ('2021-12-10') TO (... DETAIL: The lower bound of partition "sales_error" is not equal to the upper bound of partition "sales_dec2021". HINT: ALTER TABLE ... SPLIT PARTITION requires the new partition bounds to be adjacent. -- sales_error intersects with sales_dec2021 (exactly the same bounds) --- ERROR: can not split to partition "sales_error" together with partition "sales_dec2021" +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_others INTO (PARTITION sales_dec2021 FOR VALUES FROM ('2021-12-01') TO ('2022-01-01'), PARTITION sales_error FOR VALUES FROM ('2021-12-01') TO ('2022-01-01'), @@ -508,8 +503,7 @@ LINE 3: PARTITION sales_error FOR VALUES FROM ('2021-12-01') TO (... ^ DETAIL: The lower bound of partition "sales_error" is not equal to the upper bound of partition "sales_dec2021". HINT: ALTER TABLE ... SPLIT PARTITION requires the new partition bounds to be adjacent. --- ERROR: can not split DEFAULT partition "sales_others" --- HINT: To split DEFAULT partition one of the new partition must be DEFAULT. +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_others INTO (PARTITION sales_dec2021 FOR VALUES FROM ('2021-12-01') TO ('2022-01-01'), PARTITION sales_jan2022 FOR VALUES FROM ('2022-01-01') TO ('2022-02-01'), @@ -579,11 +573,11 @@ SELECT pg_get_constraintdef(oid), conname, conkey FROM pg_constraint WHERE conre FOREIGN KEY (salesperson_id) REFERENCES salespeople(salesperson_id) | sales_range_salesperson_id_fkey | {1} (2 rows) --- ERROR: new row for relation "sales_mar2022" violates check constraint "sales_range_sales_amount_check" +-- ERROR INSERT INTO sales_range VALUES (1, 0, '2022-03-11'); ERROR: new row for relation "sales_mar2022" violates check constraint "sales_range_sales_amount_check" DETAIL: Failing row contains (1, 0, 03-11-2022). --- ERROR: insert or update on table "sales_mar2022" violates foreign key constraint "sales_range_salesperson_id_fkey" +-- ERROR INSERT INTO sales_range VALUES (-1, 10, '2022-03-11'); ERROR: insert or update on table "sales_mar2022" violates foreign key constraint "sales_range_salesperson_id_fkey" DETAIL: Key (salesperson_id)=(-1) is not present in table "salespeople". @@ -637,7 +631,7 @@ SELECT tableoid::regclass, * FROM salespeople ORDER BY tableoid::regclass::text salespeople30_40 | 30 | Ford (5 rows) --- ERROR: insert or update on table "sales" violates foreign key constraint "sales_salesperson_id_fkey" +-- ERROR INSERT INTO sales VALUES (40, 50, '2022-03-04'); ERROR: insert or update on table "sales" violates foreign key constraint "sales_salesperson_id_fkey" DETAIL: Key (salesperson_id)=(40) is not present in table "salespeople". @@ -857,7 +851,7 @@ CREATE TABLE sales_list (sales_state VARCHAR(20)) PARTITION BY LIST (sales_state CREATE TABLE sales_nord PARTITION OF sales_list FOR VALUES IN ('Oslo', 'St. Petersburg', 'Helsinki'); CREATE TABLE sales_all PARTITION OF sales_list FOR VALUES IN ('Warsaw', 'Lisbon', 'New York', 'Madrid', 'Beijing', 'Berlin', 'Delhi', 'Kyiv', 'Vladivostok'); CREATE TABLE sales_others PARTITION OF sales_list DEFAULT; --- ERROR: new partition "sales_east" would overlap with another (not split) partition "sales_nord" +-- ERROR ALTER TABLE sales_list SPLIT PARTITION sales_all INTO (PARTITION sales_west FOR VALUES IN ('Lisbon', 'New York', 'Madrid'), PARTITION sales_east FOR VALUES IN ('Beijing', 'Delhi', 'Vladivostok', 'Helsinki'), @@ -865,7 +859,7 @@ ALTER TABLE sales_list SPLIT PARTITION sales_all INTO ERROR: new partition "sales_east" would overlap with another (not split) partition "sales_nord" LINE 3: ...FOR VALUES IN ('Beijing', 'Delhi', 'Vladivostok', 'Helsinki'... ^ --- ERROR: new partition "sales_west" would overlap with another new partition "sales_central" +-- ERROR ALTER TABLE sales_list SPLIT PARTITION sales_all INTO (PARTITION sales_west FOR VALUES IN ('Lisbon', 'New York', 'Madrid'), PARTITION sales_east FOR VALUES IN ('Beijing', 'Delhi', 'Vladivostok'), @@ -873,7 +867,7 @@ ALTER TABLE sales_list SPLIT PARTITION sales_all INTO ERROR: new partition "sales_west" would overlap with another new partition "sales_central" LINE 2: (PARTITION sales_west FOR VALUES IN ('Lisbon', 'New York',... ^ --- ERROR: new partition "sales_west" cannot have NULL value because split partition "sales_all" does not have +-- ERROR ALTER TABLE sales_list SPLIT PARTITION sales_all INTO (PARTITION sales_west FOR VALUES IN ('Lisbon', 'New York', 'Madrid', NULL), PARTITION sales_east FOR VALUES IN ('Beijing', 'Delhi', 'Vladivostok'), @@ -881,7 +875,7 @@ ALTER TABLE sales_list SPLIT PARTITION sales_all INTO ERROR: new partition "sales_west" cannot have NULL value because split partition "sales_all" does not have LINE 2: ...s_west FOR VALUES IN ('Lisbon', 'New York', 'Madrid', NULL), ^ --- ERROR: new partition "sales_west" cannot have this value because split partition "sales_all" does not have +-- ERROR ALTER TABLE sales_list SPLIT PARTITION sales_all INTO (PARTITION sales_west FOR VALUES IN ('Lisbon', 'New York', 'Madrid', 'Melbourne'), PARTITION sales_east FOR VALUES IN ('Beijing', 'Delhi', 'Vladivostok'), @@ -889,7 +883,7 @@ ALTER TABLE sales_list SPLIT PARTITION sales_all INTO ERROR: new partition "sales_west" cannot have this value because split partition "sales_all" does not have LINE 2: ...st FOR VALUES IN ('Lisbon', 'New York', 'Madrid', 'Melbourne... ^ --- ERROR: new partition cannot be DEFAULT because DEFAULT partition "sales_others" already exists +-- ERROR ALTER TABLE sales_list SPLIT PARTITION sales_all INTO (PARTITION sales_west FOR VALUES IN ('Lisbon', 'New York', 'Madrid', 'Melbourne'), PARTITION sales_east FOR VALUES IN ('Beijing', 'Delhi', 'Vladivostok'), @@ -903,7 +897,7 @@ DROP TABLE sales_list; -- Test for non-symbolic comparison of values (numeric values '0' and '0.0' are equal). CREATE TABLE t (a numeric) PARTITION BY LIST (a); CREATE TABLE t1 PARTITION OF t FOR VALUES in ('0', '1'); --- ERROR: new partition "x" would overlap with another new partition "x1" +-- ERROR ALTER TABLE t SPLIT PARTITION t1 INTO (PARTITION x FOR VALUES IN ('0'), PARTITION x1 FOR VALUES IN ('0.0', '1')); @@ -919,23 +913,21 @@ DROP TABLE t; CREATE TABLE sales_list(sales_state VARCHAR(20)) PARTITION BY LIST (sales_state); CREATE TABLE sales_nord PARTITION OF sales_list FOR VALUES IN ('Helsinki', 'St. Petersburg', 'Oslo'); CREATE TABLE sales_all PARTITION OF sales_list FOR VALUES IN ('Warsaw', 'Lisbon', 'New York', 'Madrid', 'Beijing', 'Berlin', 'Delhi', 'Kyiv', 'Vladivostok', NULL); --- ERROR: new partitions combined partition bounds do not contain value (NULL) but split partition "sales_all" does --- HINT: ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition. +-- ERROR ALTER TABLE sales_list SPLIT PARTITION sales_all INTO (PARTITION sales_west FOR VALUES IN ('Lisbon', 'New York', 'Madrid'), PARTITION sales_east FOR VALUES IN ('Beijing', 'Delhi', 'Vladivostok'), PARTITION sales_central FOR VALUES IN ('Warsaw', 'Berlin', 'Kyiv')); ERROR: new partitions combined partition bounds do not contain value (NULL) but split partition "sales_all" does HINT: ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition. --- ERROR: new partitions combined partition bounds do not contain value ('Kyiv'::character varying(20)) but split partition "sales_all" does --- HINT: ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition. +-- ERROR ALTER TABLE sales_list SPLIT PARTITION sales_all INTO (PARTITION sales_west FOR VALUES IN ('Lisbon', 'New York', 'Madrid'), PARTITION sales_east FOR VALUES IN ('Beijing', 'Delhi', 'Vladivostok'), PARTITION sales_central FOR VALUES IN ('Warsaw', 'Berlin', NULL)); ERROR: new partitions combined partition bounds do not contain value ('Kyiv'::character varying(20)) but split partition "sales_all" does HINT: ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition. --- ERROR DEFAULT partition should be one +-- ERROR ALTER TABLE sales_list SPLIT PARTITION sales_all INTO (PARTITION sales_west FOR VALUES IN ('Lisbon', 'New York', 'Madrid'), PARTITION sales_east FOR VALUES IN ('Beijing', 'Delhi', 'Vladivostok'), @@ -1203,7 +1195,7 @@ DROP TABLE sales_range; CREATE TABLE t1(i int, t text) PARTITION BY LIST (t); CREATE TABLE t1pa PARTITION OF t1 FOR VALUES IN ('A'); CREATE TABLE t2 (i int, t text) PARTITION BY RANGE (t); --- ERROR: relation "t1pa" is not a partition of relation "t2" +-- ERROR ALTER TABLE t2 SPLIT PARTITION t1pa INTO (PARTITION t2a FOR VALUES FROM ('A') TO ('B'), PARTITION t2b FOR VALUES FROM ('B') TO ('C')); @@ -1225,7 +1217,7 @@ SELECT c.oid::pg_catalog.regclass, pg_catalog.pg_get_expr(c.relpartbound, c.oid) tp_0_2 | FOR VALUES FROM (0) TO (2) | t (1 row) --- ERROR: cannot create a permanent relation as partition of temporary relation "t" +-- ERROR ALTER TABLE t SPLIT PARTITION tp_0_2 INTO (PARTITION tp_0_1 FOR VALUES FROM (0) TO (1), PARTITION tp_1_2 FOR VALUES FROM (1) TO (2)); @@ -1456,12 +1448,12 @@ DROP ROLE regress_partition_split_bob; CREATE TABLE t (i int) PARTITION BY HASH(i); CREATE TABLE tp1 PARTITION OF t FOR VALUES WITH (MODULUS 2, REMAINDER 0); CREATE TABLE tp2 PARTITION OF t FOR VALUES WITH (MODULUS 2, REMAINDER 1); --- ERROR: partition of hash-partitioned table cannot be split +-- ERROR ALTER TABLE t SPLIT PARTITION tp1 INTO (PARTITION tp1_1 FOR VALUES WITH (MODULUS 4, REMAINDER 0), PARTITION tp1_2 FOR VALUES WITH (MODULUS 4, REMAINDER 2)); ERROR: partition of hash-partitioned table cannot be split --- ERROR: list of new partitions should contain at least two partitions +-- ERROR ALTER TABLE t SPLIT PARTITION tp1 INTO (PARTITION tp1_1 FOR VALUES WITH (MODULUS 4, REMAINDER 0)); ERROR: list of new partitions should contain at least two partitions diff --git a/src/test/regress/sql/partition_merge.sql b/src/test/regress/sql/partition_merge.sql index a211fee2ad1..1e14ed40f5c 100644 --- a/src/test/regress/sql/partition_merge.sql +++ b/src/test/regress/sql/partition_merge.sql @@ -27,21 +27,19 @@ ALTER TABLE sales_range ATTACH PARTITION sales_apr2022 FOR VALUES FROM ('2022-04 CREATE TABLE sales_others PARTITION OF sales_range DEFAULT; --- ERROR: partition with name "sales_feb2022" is already used +-- ERROR ALTER TABLE sales_range MERGE PARTITIONS (sales_feb2022, sales_mar2022, sales_feb2022) INTO sales_feb_mar_apr2022; --- ERROR: "sales_apr2022" is not a table +-- ERROR ALTER TABLE sales_range MERGE PARTITIONS (sales_feb2022, sales_mar2022, sales_apr2022) INTO sales_feb_mar_apr2022; --- ERROR: can not merge partition "sales_mar2022" together with partition "sales_jan2022" --- DETAIL: lower bound of partition "sales_mar2022" is not equal to the upper bound of partition "sales_jan2022" +-- ERROR -- (space between sections sales_jan2022 and sales_mar2022) ALTER TABLE sales_range MERGE PARTITIONS (sales_jan2022, sales_mar2022) INTO sales_jan_mar2022; --- ERROR: can not merge partition "sales_jan2022" together with partition "sales_dec2021" --- DETAIL: lower bound of partition "sales_jan2022" is not equal to the upper bound of partition "sales_dec2021" +-- ERROR -- (space between sections sales_dec2021 and sales_jan2022) ALTER TABLE sales_range MERGE PARTITIONS (sales_dec2021, sales_jan2022, sales_feb2022) INTO sales_dec_jan_feb2022; --- ERROR: partition with name "sales_feb2022" is already used +-- ERROR ALTER TABLE sales_range MERGE PARTITIONS (sales_feb2022, sales_mar2022, partitions_merge_schema.sales_feb2022) INTO sales_feb_mar_apr2022; ---ERROR, sales_apr_2 already exists +-- ERROR ALTER TABLE sales_range MERGE PARTITIONS (sales_feb2022, sales_mar2022, sales_jan2022) INTO sales_apr_2; CREATE VIEW jan2022v as SELECT * FROM sales_jan2022; @@ -357,11 +355,11 @@ CREATE TABLE sales_others2 PARTITION OF sales_list2 DEFAULT; CREATE TABLE sales_external (LIKE sales_list); CREATE TABLE sales_external2 (vch VARCHAR(5)); --- ERROR: "sales_external" is not a partition of partitioned table "sales_list" +-- ERROR ALTER TABLE sales_list MERGE PARTITIONS (sales_west, sales_east, sales_external) INTO sales_all; --- ERROR: "sales_external2" is not a partition of partitioned table "sales_list" +-- ERROR ALTER TABLE sales_list MERGE PARTITIONS (sales_west, sales_east, sales_external2) INTO sales_all; --- ERROR: relation "sales_nord2" is not a partition of relation "sales_list" +-- ERROR ALTER TABLE sales_list MERGE PARTITIONS (sales_west, sales_nord2, sales_east) INTO sales_all; DROP TABLE sales_external2; @@ -438,9 +436,9 @@ CREATE TABLE t2 (i int, t text) PARTITION BY RANGE (t); CREATE TABLE t2pa PARTITION OF t2 FOR VALUES FROM ('A') TO ('C'); CREATE TABLE t3 (i int, t text); --- ERROR: relation "t1p1" is not a partition of relation "t2" +-- ERROR ALTER TABLE t2 MERGE PARTITIONS (t1p1, t2pa) INTO t2p; --- ERROR: "t3" is not a partition of partitioned table "t2" +-- ERROR ALTER TABLE t2 MERGE PARTITIONS (t2pa, t3) INTO t2p; DROP TABLE t3; @@ -481,7 +479,7 @@ ALTER TABLE t MERGE PARTITIONS (tp_0_2, tp_2_3) INTO pg_temp.tp_0_3; -- Partition should be temporary. EXECUTE get_partition_info('{t}'); --- ERROR: cannot create a permanent relation as partition of temporary relation "t" +-- ERROR ALTER TABLE t MERGE PARTITIONS (tp_0_3, tp_3_4) INTO tp_0_4; ROLLBACK; @@ -567,19 +565,19 @@ CREATE TABLE tp_0_1 PARTITION OF t FOR VALUES FROM (0) TO (1); CREATE TABLE tp_1_2 PARTITION OF t FOR VALUES FROM (1) TO (2); SET SESSION AUTHORIZATION regress_partition_merge_bob; --- ERROR: must be owner of table t +-- ERROR ALTER TABLE t MERGE PARTITIONS (tp_0_1, tp_1_2) INTO tp_0_2; RESET SESSION AUTHORIZATION; ALTER TABLE t OWNER TO regress_partition_merge_bob; SET SESSION AUTHORIZATION regress_partition_merge_bob; --- ERROR: must be owner of table tp_0_1 +-- ERROR ALTER TABLE t MERGE PARTITIONS (tp_0_1, tp_1_2) INTO tp_0_2; RESET SESSION AUTHORIZATION; ALTER TABLE tp_0_1 OWNER TO regress_partition_merge_bob; SET SESSION AUTHORIZATION regress_partition_merge_bob; --- ERROR: must be owner of table tp_1_2 +-- ERROR ALTER TABLE t MERGE PARTITIONS (tp_0_1, tp_1_2) INTO tp_0_2; RESET SESSION AUTHORIZATION; @@ -607,7 +605,7 @@ ALTER TABLE t ATTACH PARTITION tp_1_2 FOR VALUES FROM (1) TO (2); -- Owner is 'regress_partition_merge_bob': \dt tp_1_2 --- ERROR: partitions being merged have different owners +-- ERROR ALTER TABLE t MERGE PARTITIONS (tp_0_1, tp_1_2) INTO tp_0_2; DROP TABLE t; @@ -622,10 +620,10 @@ CREATE TABLE t (i int) PARTITION BY HASH(i); CREATE TABLE tp1 PARTITION OF t FOR VALUES WITH (MODULUS 2, REMAINDER 0); CREATE TABLE tp2 PARTITION OF t FOR VALUES WITH (MODULUS 2, REMAINDER 1); --- ERROR: partition of hash-partitioned table cannot be merged +-- ERROR ALTER TABLE t MERGE PARTITIONS (tp1, tp2) INTO tp3; --- ERROR: list of partitions to be merged should include at least two partitions +-- ERROR ALTER TABLE t MERGE PARTITIONS (tp1) INTO tp3; DROP TABLE t; @@ -712,7 +710,7 @@ ALTER TABLE t MERGE PARTITIONS (tp_0_1, tp_1_2) INTO tp_0_2; -- Should be NOT VALID FOREIGN KEY \d tp_0_2 --- ERROR: insert or update on table "t_fk" violates foreign key constraint "t_fk_i_fkey" +-- ERROR ALTER TABLE t_fk VALIDATE CONSTRAINT t_fk_i_fkey; DROP TABLE t_fk; @@ -731,7 +729,7 @@ ALTER TABLE t MERGE PARTITIONS (tp_0_1, tp_1_2) INTO tp_0_2; -- Should be NOT ENFORCED FOREIGN KEY \d tp_0_2 --- ERROR: insert or update on table "t_fk" violates foreign key constraint "t_fk_i_fkey" +-- ERROR ALTER TABLE t_fk ALTER CONSTRAINT t_fk_i_fkey ENFORCED; DROP TABLE t_fk; @@ -774,7 +772,7 @@ INSERT INTO t VALUES (5), (15); ALTER TABLE t MERGE PARTITIONS (tp_1, tp_2) INTO tp_12; INSERT INTO t VALUES (16); --- ERROR: new row for relation "tp_12" violates check constraint "t_i_check" +-- ERROR INSERT INTO t VALUES (0); -- Should be 3 rows: (5), (15), (16): SELECT i FROM t ORDER BY i; diff --git a/src/test/regress/sql/partition_split.sql b/src/test/regress/sql/partition_split.sql index 44fcf208ac6..a110fc87867 100644 --- a/src/test/regress/sql/partition_split.sql +++ b/src/test/regress/sql/partition_split.sql @@ -19,75 +19,72 @@ CREATE TABLE sales_jan2022 PARTITION OF sales_range FOR VALUES FROM ('2022-01-01 CREATE TABLE sales_feb_mar_apr2022 PARTITION OF sales_range FOR VALUES FROM ('2022-02-01') TO ('2022-05-01'); CREATE TABLE sales_others PARTITION OF sales_range DEFAULT; --- ERROR: relation "sales_xxx" does not exist +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_xxx INTO (PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'), PARTITION sales_mar2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'), PARTITION sales_apr2022 FOR VALUES FROM ('2022-04-01') TO ('2022-05-01')); --- ERROR: relation "sales_jan2022" already exists +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_jan2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'), PARTITION sales_mar2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'), PARTITION sales_apr2022 FOR VALUES FROM ('2022-04-01') TO ('2022-05-01')); --- ERROR: invalid bound specification for a range partition +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_jan2022 FOR VALUES IN ('2022-05-01', '2022-06-01'), PARTITION sales_mar2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'), PARTITION sales_apr2022 FOR VALUES FROM ('2022-04-01') TO ('2022-05-01')); --- ERROR: empty range bound specified for partition "sales_mar2022" +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'), PARTITION sales_mar2022 FOR VALUES FROM ('2022-03-01') TO ('2022-02-01'), PARTITION sales_apr2022 FOR VALUES FROM ('2022-04-01') TO ('2022-05-01')); ---ERROR: list of split partitions should contain at least two items +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-01') TO ('2022-10-01')); --- ERROR: lower bound of partition "sales_feb2022" is not equal to lower bound of split partition "sales_feb_mar_apr2022" --- HINT: ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition. +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_feb2022 FOR VALUES FROM ('2022-01-01') TO ('2022-03-01'), PARTITION sales_mar2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'), PARTITION sales_apr2022 FOR VALUES FROM ('2022-04-01') TO ('2022-05-01')); --- ERROR: partition with name "sales_feb_mar_apr2022" is already used +-- ERROR -- (We can create partition with the same name as split partition, but can't create two partitions with the same name) ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_feb_mar_apr2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'), PARTITION sales_feb_mar_apr2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'), PARTITION sales_apr2022 FOR VALUES FROM ('2022-04-01') TO ('2022-05-01')); --- ERROR: partition with name "sales_feb2022" is already used +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'), PARTITION sales_feb2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'), PARTITION sales_apr2022 FOR VALUES FROM ('2022-04-01') TO ('2022-05-01')); --- ERROR: partition with name "sales_feb2022" is already used +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'), PARTITION partition_split_schema.sales_feb2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'), PARTITION sales_apr2022 FOR VALUES FROM ('2022-04-01') TO ('2022-05-01')); --- ERROR: ALTER action SPLIT PARTITION cannot be performed on relation "sales_feb_mar_apr2022" --- DETAIL: This operation is not supported for tables. +-- ERROR ALTER TABLE sales_feb_mar_apr2022 SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_jan2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'), PARTITION sales_feb2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'), PARTITION sales_apr2022 FOR VALUES FROM ('2022-04-01') TO ('2022-05-01')); --- ERROR: upper bound of partition "sales_apr2022" is not equal to upper bound of split partition "sales_feb_mar_apr2022" --- HINT: ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition. +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'), PARTITION sales_mar2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'), PARTITION sales_apr2022 FOR VALUES FROM ('2022-04-01') TO ('2022-06-01')); --- ERROR: can not split to partition "sales_mar2022" together with partition "sales_feb2022" +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'), PARTITION sales_mar2022 FOR VALUES FROM ('2022-02-01') TO ('2022-04-01'), @@ -96,8 +93,7 @@ ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO -- Tests for spaces between partitions, them should be executed without DEFAULT partition ALTER TABLE sales_range DETACH PARTITION sales_others; --- ERROR: lower bound of partition "sales_feb2022" is not equal to lower bound of split partition "sales_feb_mar_apr2022" --- HINT: ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition. +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-02') TO ('2022-03-01'), PARTITION sales_mar2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'), @@ -121,8 +117,7 @@ CREATE TABLE sales_range (sales_date date) PARTITION BY RANGE (sales_date); CREATE TABLE sales_jan2022 PARTITION OF sales_range FOR VALUES FROM ('2022-01-01') TO ('2022-02-01'); CREATE TABLE sales_feb_mar_apr2022 PARTITION OF sales_range FOR VALUES FROM ('2022-02-01') TO ('2022-05-01'); --- ERROR: upper bound of partition "sales_apr2022" is not equal to upper bound of split partition "sales_feb_mar_apr2022" --- HINT: ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition. +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_feb_mar_apr2022 INTO (PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'), PARTITION sales_mar2022 FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'), @@ -299,7 +294,7 @@ CREATE TABLE sales_range (salesperson_id INT, sales_date date) PARTITION BY RANG CREATE TABLE sales_others PARTITION OF sales_range DEFAULT; -- sales_error intersects with sales_dec2021 (lower bound) --- ERROR: can not split to partition "sales_error" together with partition "sales_dec2021" +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_others INTO (PARTITION sales_dec2021 FOR VALUES FROM ('2021-12-01') TO ('2022-01-01'), PARTITION sales_error FOR VALUES FROM ('2021-12-30') TO ('2022-02-01'), @@ -307,7 +302,7 @@ ALTER TABLE sales_range SPLIT PARTITION sales_others INTO PARTITION sales_others DEFAULT); -- sales_error intersects with sales_feb2022 (upper bound) --- ERROR: can not split to partition "sales_feb2022" together with partition "sales_error" +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_others INTO (PARTITION sales_dec2021 FOR VALUES FROM ('2021-12-01') TO ('2022-01-01'), PARTITION sales_error FOR VALUES FROM ('2022-01-01') TO ('2022-02-02'), @@ -315,7 +310,7 @@ ALTER TABLE sales_range SPLIT PARTITION sales_others INTO PARTITION sales_others DEFAULT); -- sales_error intersects with sales_dec2021 (inside bound) --- ERROR: can not split to partition "sales_error" together with partition "sales_dec2021" +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_others INTO (PARTITION sales_dec2021 FOR VALUES FROM ('2021-12-01') TO ('2022-01-01'), PARTITION sales_error FOR VALUES FROM ('2021-12-10') TO ('2021-12-20'), @@ -323,15 +318,14 @@ ALTER TABLE sales_range SPLIT PARTITION sales_others INTO PARTITION sales_others DEFAULT); -- sales_error intersects with sales_dec2021 (exactly the same bounds) --- ERROR: can not split to partition "sales_error" together with partition "sales_dec2021" +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_others INTO (PARTITION sales_dec2021 FOR VALUES FROM ('2021-12-01') TO ('2022-01-01'), PARTITION sales_error FOR VALUES FROM ('2021-12-01') TO ('2022-01-01'), PARTITION sales_feb2022 FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'), PARTITION sales_others DEFAULT); --- ERROR: can not split DEFAULT partition "sales_others" --- HINT: To split DEFAULT partition one of the new partition must be DEFAULT. +-- ERROR ALTER TABLE sales_range SPLIT PARTITION sales_others INTO (PARTITION sales_dec2021 FOR VALUES FROM ('2021-12-01') TO ('2022-01-01'), PARTITION sales_jan2022 FOR VALUES FROM ('2022-01-01') TO ('2022-02-01'), @@ -385,9 +379,9 @@ SELECT pg_get_constraintdef(oid), conname, conkey FROM pg_constraint WHERE conre SELECT pg_get_constraintdef(oid), conname, conkey FROM pg_constraint WHERE conrelid = 'sales_mar2022'::regclass::oid ORDER BY conname COLLATE "C"; SELECT pg_get_constraintdef(oid), conname, conkey FROM pg_constraint WHERE conrelid = 'sales_apr2022'::regclass::oid ORDER BY conname COLLATE "C"; --- ERROR: new row for relation "sales_mar2022" violates check constraint "sales_range_sales_amount_check" +-- ERROR INSERT INTO sales_range VALUES (1, 0, '2022-03-11'); --- ERROR: insert or update on table "sales_mar2022" violates foreign key constraint "sales_range_salesperson_id_fkey" +-- ERROR INSERT INTO sales_range VALUES (-1, 10, '2022-03-11'); -- ok INSERT INTO sales_range VALUES (1, 10, '2022-03-11'); @@ -430,7 +424,7 @@ ALTER TABLE salespeople SPLIT PARTITION salespeople10_40 INTO SELECT tableoid::regclass, * FROM salespeople ORDER BY tableoid::regclass::text COLLATE "C", salesperson_id; --- ERROR: insert or update on table "sales" violates foreign key constraint "sales_salesperson_id_fkey" +-- ERROR INSERT INTO sales VALUES (40, 50, '2022-03-04'); -- ok INSERT INTO sales VALUES (30, 50, '2022-03-04'); @@ -608,31 +602,31 @@ CREATE TABLE sales_nord PARTITION OF sales_list FOR VALUES IN ('Oslo', 'St. Pete CREATE TABLE sales_all PARTITION OF sales_list FOR VALUES IN ('Warsaw', 'Lisbon', 'New York', 'Madrid', 'Beijing', 'Berlin', 'Delhi', 'Kyiv', 'Vladivostok'); CREATE TABLE sales_others PARTITION OF sales_list DEFAULT; --- ERROR: new partition "sales_east" would overlap with another (not split) partition "sales_nord" +-- ERROR ALTER TABLE sales_list SPLIT PARTITION sales_all INTO (PARTITION sales_west FOR VALUES IN ('Lisbon', 'New York', 'Madrid'), PARTITION sales_east FOR VALUES IN ('Beijing', 'Delhi', 'Vladivostok', 'Helsinki'), PARTITION sales_central FOR VALUES IN ('Warsaw', 'Berlin', 'Kyiv')); --- ERROR: new partition "sales_west" would overlap with another new partition "sales_central" +-- ERROR ALTER TABLE sales_list SPLIT PARTITION sales_all INTO (PARTITION sales_west FOR VALUES IN ('Lisbon', 'New York', 'Madrid'), PARTITION sales_east FOR VALUES IN ('Beijing', 'Delhi', 'Vladivostok'), PARTITION sales_central FOR VALUES IN ('Warsaw', 'Berlin', 'Lisbon', 'Kyiv')); --- ERROR: new partition "sales_west" cannot have NULL value because split partition "sales_all" does not have +-- ERROR ALTER TABLE sales_list SPLIT PARTITION sales_all INTO (PARTITION sales_west FOR VALUES IN ('Lisbon', 'New York', 'Madrid', NULL), PARTITION sales_east FOR VALUES IN ('Beijing', 'Delhi', 'Vladivostok'), PARTITION sales_central FOR VALUES IN ('Warsaw', 'Berlin', 'Kyiv')); --- ERROR: new partition "sales_west" cannot have this value because split partition "sales_all" does not have +-- ERROR ALTER TABLE sales_list SPLIT PARTITION sales_all INTO (PARTITION sales_west FOR VALUES IN ('Lisbon', 'New York', 'Madrid', 'Melbourne'), PARTITION sales_east FOR VALUES IN ('Beijing', 'Delhi', 'Vladivostok'), PARTITION sales_central FOR VALUES IN ('Warsaw', 'Berlin', 'Kyiv')); --- ERROR: new partition cannot be DEFAULT because DEFAULT partition "sales_others" already exists +-- ERROR ALTER TABLE sales_list SPLIT PARTITION sales_all INTO (PARTITION sales_west FOR VALUES IN ('Lisbon', 'New York', 'Madrid', 'Melbourne'), PARTITION sales_east FOR VALUES IN ('Beijing', 'Delhi', 'Vladivostok'), @@ -644,7 +638,7 @@ DROP TABLE sales_list; -- Test for non-symbolic comparison of values (numeric values '0' and '0.0' are equal). CREATE TABLE t (a numeric) PARTITION BY LIST (a); CREATE TABLE t1 PARTITION OF t FOR VALUES in ('0', '1'); --- ERROR: new partition "x" would overlap with another new partition "x1" +-- ERROR ALTER TABLE t SPLIT PARTITION t1 INTO (PARTITION x FOR VALUES IN ('0'), PARTITION x1 FOR VALUES IN ('0.0', '1')); @@ -660,21 +654,19 @@ CREATE TABLE sales_list(sales_state VARCHAR(20)) PARTITION BY LIST (sales_state) CREATE TABLE sales_nord PARTITION OF sales_list FOR VALUES IN ('Helsinki', 'St. Petersburg', 'Oslo'); CREATE TABLE sales_all PARTITION OF sales_list FOR VALUES IN ('Warsaw', 'Lisbon', 'New York', 'Madrid', 'Beijing', 'Berlin', 'Delhi', 'Kyiv', 'Vladivostok', NULL); --- ERROR: new partitions combined partition bounds do not contain value (NULL) but split partition "sales_all" does --- HINT: ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition. +-- ERROR ALTER TABLE sales_list SPLIT PARTITION sales_all INTO (PARTITION sales_west FOR VALUES IN ('Lisbon', 'New York', 'Madrid'), PARTITION sales_east FOR VALUES IN ('Beijing', 'Delhi', 'Vladivostok'), PARTITION sales_central FOR VALUES IN ('Warsaw', 'Berlin', 'Kyiv')); --- ERROR: new partitions combined partition bounds do not contain value ('Kyiv'::character varying(20)) but split partition "sales_all" does --- HINT: ALTER TABLE ... SPLIT PARTITION require combined bounds of new partitions must exactly match the bound of the split partition. +-- ERROR ALTER TABLE sales_list SPLIT PARTITION sales_all INTO (PARTITION sales_west FOR VALUES IN ('Lisbon', 'New York', 'Madrid'), PARTITION sales_east FOR VALUES IN ('Beijing', 'Delhi', 'Vladivostok'), PARTITION sales_central FOR VALUES IN ('Warsaw', 'Berlin', NULL)); --- ERROR DEFAULT partition should be one +-- ERROR ALTER TABLE sales_list SPLIT PARTITION sales_all INTO (PARTITION sales_west FOR VALUES IN ('Lisbon', 'New York', 'Madrid'), PARTITION sales_east FOR VALUES IN ('Beijing', 'Delhi', 'Vladivostok'), @@ -849,7 +841,7 @@ CREATE TABLE t1(i int, t text) PARTITION BY LIST (t); CREATE TABLE t1pa PARTITION OF t1 FOR VALUES IN ('A'); CREATE TABLE t2 (i int, t text) PARTITION BY RANGE (t); --- ERROR: relation "t1pa" is not a partition of relation "t2" +-- ERROR ALTER TABLE t2 SPLIT PARTITION t1pa INTO (PARTITION t2a FOR VALUES FROM ('A') TO ('B'), PARTITION t2b FOR VALUES FROM ('B') TO ('C')); @@ -868,7 +860,7 @@ SELECT c.oid::pg_catalog.regclass, pg_catalog.pg_get_expr(c.relpartbound, c.oid) WHERE c.oid = i.inhrelid AND i.inhparent = 't'::regclass ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT', c.oid::pg_catalog.regclass::pg_catalog.text COLLATE "C"; --- ERROR: cannot create a permanent relation as partition of temporary relation "t" +-- ERROR ALTER TABLE t SPLIT PARTITION tp_0_2 INTO (PARTITION tp_0_1 FOR VALUES FROM (0) TO (1), PARTITION tp_1_2 FOR VALUES FROM (1) TO (2)); @@ -1033,12 +1025,12 @@ CREATE TABLE t (i int) PARTITION BY HASH(i); CREATE TABLE tp1 PARTITION OF t FOR VALUES WITH (MODULUS 2, REMAINDER 0); CREATE TABLE tp2 PARTITION OF t FOR VALUES WITH (MODULUS 2, REMAINDER 1); --- ERROR: partition of hash-partitioned table cannot be split +-- ERROR ALTER TABLE t SPLIT PARTITION tp1 INTO (PARTITION tp1_1 FOR VALUES WITH (MODULUS 4, REMAINDER 0), PARTITION tp1_2 FOR VALUES WITH (MODULUS 4, REMAINDER 2)); --- ERROR: list of new partitions should contain at least two partitions +-- ERROR ALTER TABLE t SPLIT PARTITION tp1 INTO (PARTITION tp1_1 FOR VALUES WITH (MODULUS 4, REMAINDER 0)); -- 2.43.0