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

Commit74aa7e0

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 parent20b4ed8 commit74aa7e0

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
@@ -722,7 +722,7 @@ DefineIndex(Oid relationId,
722722
errdetail("%s constraints cannot be used when partition keys include expressions.",
723723
constraint_type)));
724724

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

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,3 +1384,6 @@ insert into covidxpart values (4, 1);
13841384
insert into covidxpart values (4, 1);
13851385
ERROR: duplicate key value violates unique constraint "covidxpart4_a_b_idx"
13861386
DETAIL: Key (a)=(4) already exists.
1387+
create unique index on covidxpart (b) include (a); -- should fail
1388+
ERROR: insufficient columns in UNIQUE constraint definition
1389+
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
@@ -739,3 +739,4 @@ create unique index on covidxpart4 (a);
739739
altertable covidxpart attach partition covidxpart4 forvaluesin (4);
740740
insert into covidxpartvalues (4,1);
741741
insert into covidxpartvalues (4,1);
742+
createunique indexon covidxpart (b) include (a);-- should fail

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp