@@ -907,16 +907,16 @@ Indexes:
907
907
drop table idxpart;
908
908
-- Failing to use the full partition key is not allowed
909
909
create table idxpart (a int unique, b int) partition by range (a, b);
910
- ERROR: insufficient columns in UNIQUE constraint definition
910
+ ERROR: unique constraint on partitioned table must include all partitioning columns
911
911
DETAIL: UNIQUE constraint on table "idxpart" lacks column "b" which is part of the partition key.
912
912
create table idxpart (a int, b int unique) partition by range (a, b);
913
- ERROR: insufficient columns in UNIQUE constraint definition
913
+ ERROR: unique constraint on partitioned table must include all partitioning columns
914
914
DETAIL: UNIQUE constraint on table "idxpart" lacks column "a" which is part of the partition key.
915
915
create table idxpart (a int primary key, b int) partition by range (b, a);
916
- ERROR: insufficient columns in PRIMARY KEY constraint definition
916
+ ERROR: unique constraint on partitioned table must include all partitioning columns
917
917
DETAIL: PRIMARY KEY constraint on table "idxpart" lacks column "b" which is part of the partition key.
918
918
create table idxpart (a int, b int primary key) partition by range (b, a);
919
- ERROR: insufficient columns in PRIMARY KEY constraint definition
919
+ ERROR: unique constraint on partitioned table must include all partitioning columns
920
920
DETAIL: PRIMARY KEY constraint on table "idxpart" lacks column "a" which is part of the partition key.
921
921
-- OK if you use them in some other order
922
922
create table idxpart (a int, b int, c text, primary key (a, b, c)) partition by range (b, c, a);
@@ -936,7 +936,7 @@ DETAIL: UNIQUE constraints cannot be used when partition keys include expressio
936
936
-- use ALTER TABLE to add a primary key
937
937
create table idxpart (a int, b int, c text) partition by range (a, b);
938
938
alter table idxpart add primary key (a); -- not an incomplete one though
939
- ERROR: insufficient columns in PRIMARY KEY constraint definition
939
+ ERROR: unique constraint on partitioned table must include all partitioning columns
940
940
DETAIL: PRIMARY KEY constraint on table "idxpart" lacks column "b" which is part of the partition key.
941
941
alter table idxpart add primary key (a, b); -- this works
942
942
\d idxpart
@@ -967,7 +967,7 @@ drop table idxpart;
967
967
-- use ALTER TABLE to add a unique constraint
968
968
create table idxpart (a int, b int) partition by range (a, b);
969
969
alter table idxpart add unique (a); -- not an incomplete one though
970
- ERROR: insufficient columns in UNIQUE constraint definition
970
+ ERROR: unique constraint on partitioned table must include all partitioning columns
971
971
DETAIL: UNIQUE constraint on table "idxpart" lacks column "b" which is part of the partition key.
972
972
alter table idxpart add unique (b, a); -- this works
973
973
\d idxpart
@@ -1017,15 +1017,15 @@ drop table idxpart;
1017
1017
create table idxpart (a int, b int, primary key (a)) partition by range (a);
1018
1018
create table idxpart2 partition of idxpart
1019
1019
for values from (0) to (1000) partition by range (b); -- fail
1020
- ERROR: insufficient columns in PRIMARY KEY constraint definition
1020
+ ERROR: unique constraint on partitioned table must include all partitioning columns
1021
1021
DETAIL: PRIMARY KEY constraint on table "idxpart2" lacks column "b" which is part of the partition key.
1022
1022
drop table idxpart;
1023
1023
-- Ditto for the ATTACH PARTITION case
1024
1024
create table idxpart (a int unique, b int) partition by range (a);
1025
1025
create table idxpart1 (a int not null, b int, unique (a, b))
1026
1026
partition by range (a, b);
1027
1027
alter table idxpart attach partition idxpart1 for values from (1) to (1000);
1028
- ERROR: insufficient columns in UNIQUE constraint definition
1028
+ ERROR: unique constraint on partitioned table must include all partitioning columns
1029
1029
DETAIL: UNIQUE constraint on table "idxpart1" lacks column "b" which is part of the partition key.
1030
1030
DROP TABLE idxpart, idxpart1;
1031
1031
-- Multi-layer partitioning works correctly in this case:
@@ -1278,7 +1278,7 @@ insert into covidxpart values (4, 1);
1278
1278
ERROR: duplicate key value violates unique constraint "covidxpart4_a_b_idx"
1279
1279
DETAIL: Key (a)=(4) already exists.
1280
1280
create unique index on covidxpart (b) include (a); -- should fail
1281
- ERROR: insufficient columns in UNIQUE constraint definition
1281
+ ERROR: unique constraint on partitioned table must include all partitioning columns
1282
1282
DETAIL: UNIQUE constraint on table "covidxpart" lacks column "a" which is part of the partition key.
1283
1283
-- check that detaching a partition also detaches the primary key constraint
1284
1284
create table parted_pk_detach_test (a int primary key) partition by list (a);
0 commit comments