doc: Reword restriction on partition keys in unique indexes
New wording from David G. Johnston, who noticed the unreadable original also. Include his suggested test case as well. Fix a typo I noticed elsewhere while doing this. Discussion: https://postgr.es/m/CAKFQuwY4Ld7ecxL_KAmaxwt0FUu5VcPPN2L4dh+3BeYbrdBa5g@mail.gmail.com
This commit is contained in:
parent
3beb46ae81
commit
63cbee6a78
@ -791,11 +791,10 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
When used on partitioned tables, unique constraints must include all the
|
When establishing a unique constraint for a multi-level partition
|
||||||
columns of the partition key.
|
hierarchy, all the columns in the partition key of the target
|
||||||
If any partitions are in turn partitioned, all columns of each partition
|
partitioned table, as well as those of all its descendant partitioned
|
||||||
key are considered at each level below the <literal>UNIQUE</literal>
|
tables, must be included in the constraint definition.
|
||||||
constraint.
|
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
@ -3646,7 +3646,7 @@ ALTER TABLE list_parted2 ATTACH PARTITION list_parted2 FOR VALUES IN (0);
|
|||||||
ERROR: circular inheritance not allowed
|
ERROR: circular inheritance not allowed
|
||||||
DETAIL: "list_parted2" is already a child of "list_parted2".
|
DETAIL: "list_parted2" is already a child of "list_parted2".
|
||||||
-- If a partitioned table being created or an existing table being attached
|
-- If a partitioned table being created or an existing table being attached
|
||||||
-- as a paritition does not have a constraint that would allow validation scan
|
-- as a partition does not have a constraint that would allow validation scan
|
||||||
-- to be skipped, but an individual partition does, then the partition's
|
-- to be skipped, but an individual partition does, then the partition's
|
||||||
-- validation scan is skipped.
|
-- validation scan is skipped.
|
||||||
CREATE TABLE quuux (a int, b text) PARTITION BY LIST (a);
|
CREATE TABLE quuux (a int, b text) PARTITION BY LIST (a);
|
||||||
|
@ -885,6 +885,14 @@ for values from (0) to (1000) partition by range (b); -- fail
|
|||||||
ERROR: insufficient columns in PRIMARY KEY constraint definition
|
ERROR: insufficient columns in PRIMARY KEY constraint definition
|
||||||
DETAIL: PRIMARY KEY constraint on table "idxpart2" lacks column "b" which is part of the partition key.
|
DETAIL: PRIMARY KEY constraint on table "idxpart2" lacks column "b" which is part of the partition key.
|
||||||
drop table idxpart;
|
drop table idxpart;
|
||||||
|
-- Ditto for the ATTACH PARTITION case
|
||||||
|
create table idxpart (a int primary key, b int) partition by range (a);
|
||||||
|
create table idxpart1 (a int not null, b int, primary key (a, b))
|
||||||
|
partition by range (a, b);
|
||||||
|
alter table idxpart attach partition idxpart1 for values from (1) to (1000);
|
||||||
|
ERROR: insufficient columns in PRIMARY KEY constraint definition
|
||||||
|
DETAIL: PRIMARY KEY constraint on table "idxpart1" lacks column "b" which is part of the partition key.
|
||||||
|
DROP TABLE idxpart, idxpart1;
|
||||||
-- Multi-layer partitioning works correctly in this case:
|
-- Multi-layer partitioning works correctly in this case:
|
||||||
create table idxpart (a int, b int, primary key (a, b)) partition by range (a);
|
create table idxpart (a int, b int, primary key (a, b)) partition by range (a);
|
||||||
create table idxpart2 partition of idxpart for values from (0) to (1000) partition by range (b);
|
create table idxpart2 partition of idxpart for values from (0) to (1000) partition by range (b);
|
||||||
|
@ -2348,7 +2348,7 @@ ALTER TABLE part_5 ATTACH PARTITION list_parted2 FOR VALUES IN ('b');
|
|||||||
ALTER TABLE list_parted2 ATTACH PARTITION list_parted2 FOR VALUES IN (0);
|
ALTER TABLE list_parted2 ATTACH PARTITION list_parted2 FOR VALUES IN (0);
|
||||||
|
|
||||||
-- If a partitioned table being created or an existing table being attached
|
-- If a partitioned table being created or an existing table being attached
|
||||||
-- as a paritition does not have a constraint that would allow validation scan
|
-- as a partition does not have a constraint that would allow validation scan
|
||||||
-- to be skipped, but an individual partition does, then the partition's
|
-- to be skipped, but an individual partition does, then the partition's
|
||||||
-- validation scan is skipped.
|
-- validation scan is skipped.
|
||||||
CREATE TABLE quuux (a int, b text) PARTITION BY LIST (a);
|
CREATE TABLE quuux (a int, b text) PARTITION BY LIST (a);
|
||||||
|
@ -450,6 +450,13 @@ create table idxpart2 partition of idxpart
|
|||||||
for values from (0) to (1000) partition by range (b); -- fail
|
for values from (0) to (1000) partition by range (b); -- fail
|
||||||
drop table idxpart;
|
drop table idxpart;
|
||||||
|
|
||||||
|
-- Ditto for the ATTACH PARTITION case
|
||||||
|
create table idxpart (a int primary key, b int) partition by range (a);
|
||||||
|
create table idxpart1 (a int not null, b int, primary key (a, b))
|
||||||
|
partition by range (a, b);
|
||||||
|
alter table idxpart attach partition idxpart1 for values from (1) to (1000);
|
||||||
|
DROP TABLE idxpart, idxpart1;
|
||||||
|
|
||||||
-- Multi-layer partitioning works correctly in this case:
|
-- Multi-layer partitioning works correctly in this case:
|
||||||
create table idxpart (a int, b int, primary key (a, b)) partition by range (a);
|
create table idxpart (a int, b int, primary key (a, b)) partition by range (a);
|
||||||
create table idxpart2 partition of idxpart for values from (0) to (1000) partition by range (b);
|
create table idxpart2 partition of idxpart for values from (0) to (1000) partition by range (b);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user