@@ -855,16 +855,16 @@ Indexes:
855
855
drop table idxpart;
856
856
-- Failing to use the full partition key is not allowed
857
857
create table idxpart (a int unique, b int) partition by range (a, b);
858
- ERROR: insufficient columns in UNIQUE constraint definition
858
+ ERROR: unique constraint on partitioned table must include all partitioning columns
859
859
DETAIL: UNIQUE constraint on table "idxpart" lacks column "b" which is part of the partition key.
860
860
create table idxpart (a int, b int unique) partition by range (a, b);
861
- ERROR: insufficient columns in UNIQUE constraint definition
861
+ ERROR: unique constraint on partitioned table must include all partitioning columns
862
862
DETAIL: UNIQUE constraint on table "idxpart" lacks column "a" which is part of the partition key.
863
863
create table idxpart (a int primary key, b int) partition by range (b, a);
864
- ERROR: insufficient columns in PRIMARY KEY constraint definition
864
+ ERROR: unique constraint on partitioned table must include all partitioning columns
865
865
DETAIL: PRIMARY KEY constraint on table "idxpart" lacks column "b" which is part of the partition key.
866
866
create table idxpart (a int, b int primary key) partition by range (b, a);
867
- ERROR: insufficient columns in PRIMARY KEY constraint definition
867
+ ERROR: unique constraint on partitioned table must include all partitioning columns
868
868
DETAIL: PRIMARY KEY constraint on table "idxpart" lacks column "a" which is part of the partition key.
869
869
-- OK if you use them in some other order
870
870
create table idxpart (a int, b int, c text, primary key (a, b, c)) partition by range (b, c, a);
@@ -884,7 +884,7 @@ DETAIL: UNIQUE constraints cannot be used when partition keys include expressio
884
884
-- use ALTER TABLE to add a primary key
885
885
create table idxpart (a int, b int, c text) partition by range (a, b);
886
886
alter table idxpart add primary key (a); -- not an incomplete one though
887
- ERROR: insufficient columns in PRIMARY KEY constraint definition
887
+ ERROR: unique constraint on partitioned table must include all partitioning columns
888
888
DETAIL: PRIMARY KEY constraint on table "idxpart" lacks column "b" which is part of the partition key.
889
889
alter table idxpart add primary key (a, b); -- this works
890
890
\d idxpart
@@ -915,7 +915,7 @@ drop table idxpart;
915
915
-- use ALTER TABLE to add a unique constraint
916
916
create table idxpart (a int, b int) partition by range (a, b);
917
917
alter table idxpart add unique (a); -- not an incomplete one though
918
- ERROR: insufficient columns in UNIQUE constraint definition
918
+ ERROR: unique constraint on partitioned table must include all partitioning columns
919
919
DETAIL: UNIQUE constraint on table "idxpart" lacks column "b" which is part of the partition key.
920
920
alter table idxpart add unique (b, a); -- this works
921
921
\d idxpart
@@ -965,15 +965,15 @@ drop table idxpart;
965
965
create table idxpart (a int, b int, primary key (a)) partition by range (a);
966
966
create table idxpart2 partition of idxpart
967
967
for values from (0) to (1000) partition by range (b); -- fail
968
- ERROR: insufficient columns in PRIMARY KEY constraint definition
968
+ ERROR: unique constraint on partitioned table must include all partitioning columns
969
969
DETAIL: PRIMARY KEY constraint on table "idxpart2" lacks column "b" which is part of the partition key.
970
970
drop table idxpart;
971
971
-- Ditto for the ATTACH PARTITION case
972
972
create table idxpart (a int unique, b int) partition by range (a);
973
973
create table idxpart1 (a int not null, b int, unique (a, b))
974
974
partition by range (a, b);
975
975
alter table idxpart attach partition idxpart1 for values from (1) to (1000);
976
- ERROR: insufficient columns in UNIQUE constraint definition
976
+ ERROR: unique constraint on partitioned table must include all partitioning columns
977
977
DETAIL: UNIQUE constraint on table "idxpart1" lacks column "b" which is part of the partition key.
978
978
DROP TABLE idxpart, idxpart1;
979
979
-- Multi-layer partitioning works correctly in this case:
@@ -1426,7 +1426,7 @@ insert into covidxpart values (4, 1);
1426
1426
ERROR: duplicate key value violates unique constraint "covidxpart4_a_b_idx"
1427
1427
DETAIL: Key (a)=(4) already exists.
1428
1428
create unique index on covidxpart (b) include (a); -- should fail
1429
- ERROR: insufficient columns in UNIQUE constraint definition
1429
+ ERROR: unique constraint on partitioned table must include all partitioning columns
1430
1430
DETAIL: UNIQUE constraint on table "covidxpart" lacks column "a" which is part of the partition key.
1431
1431
-- check that detaching a partition also detaches the primary key constraint
1432
1432
create table parted_pk_detach_test (a int primary key) partition by list (a);
0 commit comments