@@ -907,16 +907,16 @@ Indexes:
907907drop table idxpart;
908908-- Failing to use the full partition key is not allowed
909909create 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
911911DETAIL: UNIQUE constraint on table "idxpart" lacks column "b" which is part of the partition key.
912912create 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
914914DETAIL: UNIQUE constraint on table "idxpart" lacks column "a" which is part of the partition key.
915915create 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
917917DETAIL: PRIMARY KEY constraint on table "idxpart" lacks column "b" which is part of the partition key.
918918create 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
920920DETAIL: PRIMARY KEY constraint on table "idxpart" lacks column "a" which is part of the partition key.
921921-- OK if you use them in some other order
922922create 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
936936-- use ALTER TABLE to add a primary key
937937create table idxpart (a int, b int, c text) partition by range (a, b);
938938alter 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
940940DETAIL: PRIMARY KEY constraint on table "idxpart" lacks column "b" which is part of the partition key.
941941alter table idxpart add primary key (a, b); -- this works
942942\d idxpart
@@ -967,7 +967,7 @@ drop table idxpart;
967967-- use ALTER TABLE to add a unique constraint
968968create table idxpart (a int, b int) partition by range (a, b);
969969alter 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
971971DETAIL: UNIQUE constraint on table "idxpart" lacks column "b" which is part of the partition key.
972972alter table idxpart add unique (b, a); -- this works
973973\d idxpart
@@ -1017,15 +1017,15 @@ drop table idxpart;
10171017create table idxpart (a int, b int, primary key (a)) partition by range (a);
10181018create table idxpart2 partition of idxpart
10191019for 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
10211021DETAIL: PRIMARY KEY constraint on table "idxpart2" lacks column "b" which is part of the partition key.
10221022drop table idxpart;
10231023-- Ditto for the ATTACH PARTITION case
10241024create table idxpart (a int unique, b int) partition by range (a);
10251025create table idxpart1 (a int not null, b int, unique (a, b))
10261026 partition by range (a, b);
10271027alter 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
10291029DETAIL: UNIQUE constraint on table "idxpart1" lacks column "b" which is part of the partition key.
10301030DROP TABLE idxpart, idxpart1;
10311031-- Multi-layer partitioning works correctly in this case:
@@ -1278,7 +1278,7 @@ insert into covidxpart values (4, 1);
12781278ERROR: duplicate key value violates unique constraint "covidxpart4_a_b_idx"
12791279DETAIL: Key (a)=(4) already exists.
12801280create 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
12821282DETAIL: UNIQUE constraint on table "covidxpart" lacks column "a" which is part of the partition key.
12831283-- check that detaching a partition also detaches the primary key constraint
12841284create table parted_pk_detach_test (a int primary key) partition by list (a);
0 commit comments