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 that 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 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 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;
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 that 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 that 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 that don't have sub-partitions.
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 that 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 that don't have sub-partitions.
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;
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;
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;
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;
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".
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".
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).
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'),
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'),
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'),
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'),
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'),
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'),
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'),
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'),
HINT: ALTER TABLE ... SPLIT PARTITION requires the 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'),
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'),
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'),
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 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'),
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 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'),
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 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'),
^
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 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'),
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".
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".
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'),
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'),
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'),
ERROR: new partition "sales_west" cannot have NULL value because split partition "sales_all" does not have it
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'),
ERROR: new partition "sales_west" cannot have this value because split partition "sales_all" does not have it
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'),
-- 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'));
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'),
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'));
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));
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
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;
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;
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;
-- 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;
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;
-- 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;
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;
-- 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;
-- 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;
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;
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'),
-- 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'),
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'),
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'),
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'),
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'),
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'),
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');
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');
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'),
-- 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'));
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'),
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'));
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));
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));