Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0ad41cf

Browse files
committed
Fix unique INCLUDE indexes on partitioned tables
We were considering the INCLUDE columns as part of the key, allowingunicity-violating rows to be inserted in different partitions.Concurrent development conflict ineb7ed3f and8224de4.Reported-by: Justin PryzbyDiscussion:https://postgr.es/m/20190109065109.GA4285@telsasoft.com
1 parentbb24439 commit0ad41cf

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

‎src/backend/commands/indexcmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ DefineIndex(Oid relationId,
721721
errdetail("%s constraints cannot be used when partition keys include expressions.",
722722
constraint_type)));
723723

724-
for (j=0;j<indexInfo->ii_NumIndexAttrs;j++)
724+
for (j=0;j<indexInfo->ii_NumIndexKeyAttrs;j++)
725725
{
726726
if (key->partattrs[i]==indexInfo->ii_IndexAttrNumbers[j])
727727
{

‎src/test/regress/expected/indexing.out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,3 +1411,6 @@ insert into covidxpart values (4, 1);
14111411
insert into covidxpart values (4, 1);
14121412
ERROR: duplicate key value violates unique constraint "covidxpart4_a_b_idx"
14131413
DETAIL: Key (a)=(4) already exists.
1414+
create unique index on covidxpart (b) include (a); -- should fail
1415+
ERROR: insufficient columns in UNIQUE constraint definition
1416+
DETAIL: UNIQUE constraint on table "covidxpart" lacks column "a" which is part of the partition key.

‎src/test/regress/sql/indexing.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,3 +756,4 @@ create unique index on covidxpart4 (a);
756756
altertable covidxpart attach partition covidxpart4 forvaluesin (4);
757757
insert into covidxpartvalues (4,1);
758758
insert into covidxpartvalues (4,1);
759+
createunique indexon covidxpart (b) include (a);-- should fail

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp