mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
Fix unique INCLUDE indexes on partitioned tables
We were considering the INCLUDE columns as part of the key, allowing unicity-violating rows to be inserted in different partitions. Concurrent development conflict ineb7ed3f306
and8224de4f42
. Reported-by: Justin Pryzby Discussion: https://postgr.es/m/20190109065109.GA4285@telsasoft.com
This commit is contained in:
parent
bb24439cef
commit
0ad41cf537
@ -721,7 +721,7 @@ DefineIndex(Oid relationId,
|
||||
errdetail("%s constraints cannot be used when partition keys include expressions.",
|
||||
constraint_type)));
|
||||
|
||||
for (j = 0; j < indexInfo->ii_NumIndexAttrs; j++)
|
||||
for (j = 0; j < indexInfo->ii_NumIndexKeyAttrs; j++)
|
||||
{
|
||||
if (key->partattrs[i] == indexInfo->ii_IndexAttrNumbers[j])
|
||||
{
|
||||
|
@ -1411,3 +1411,6 @@ insert into covidxpart values (4, 1);
|
||||
insert into covidxpart values (4, 1);
|
||||
ERROR: duplicate key value violates unique constraint "covidxpart4_a_b_idx"
|
||||
DETAIL: Key (a)=(4) already exists.
|
||||
create unique index on covidxpart (b) include (a); -- should fail
|
||||
ERROR: insufficient columns in UNIQUE constraint definition
|
||||
DETAIL: UNIQUE constraint on table "covidxpart" lacks column "a" which is part of the partition key.
|
||||
|
@ -756,3 +756,4 @@ create unique index on covidxpart4 (a);
|
||||
alter table covidxpart attach partition covidxpart4 for values in (4);
|
||||
insert into covidxpart values (4, 1);
|
||||
insert into covidxpart values (4, 1);
|
||||
create unique index on covidxpart (b) include (a); -- should fail
|
||||
|
Loading…
Reference in New Issue
Block a user