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

Commitb3b7f78

Browse files
committed
Fix additional breakage in covering-index patch.
CheckIndexCompatible() misused ComputeIndexAttrs() by not botheringto fill ii_NumIndexAttrs and ii_NumIndexKeyAttrs in the passedIndexInfo. Omission of ii_NumIndexAttrs was previously unimportant,but now this matters because ComputeIndexAttrs depends onii_NumIndexKeyAttrs to decide how many columns it needs to report on.(BTW, the fact that this oversight wasn't detected earlier impliesthat we have no regression test verifying whether CheckIndexCompatibleever succeeds. Bad dog. Not the job of this patch to fix it, though.)Also, change the API of ComputeIndexAttrs so that it fills the opclassoutput array for all column positions, as it does for the options outputarray; positions for non-key index columns are filled with zeroes.This isn't directly fixing any bug, but it seems like a good idea.Per valgrind failure reports from buildfarm.Alexander Korotkov, tweaked a bit by meDiscussion:https://postgr.es/m/CAPpHfduWrysrT-qAhn+3Ea5+Mg6Vhc-oA6o2Z-hRCPRdvf3tiw@mail.gmail.com
1 parent893e9e6 commitb3b7f78

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

‎src/backend/commands/indexcmds.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,13 @@ CheckIndexCompatible(Oid oldId,
182182
* the new index, so we can test whether it's compatible with the existing
183183
* one. Note that ComputeIndexAttrs might fail here, but that's OK:
184184
* DefineIndex would have called this function with the same arguments
185-
* later on, and it would have failed then anyway.
185+
* later on, and it would have failed then anyway. Our attributeList
186+
* contains only key attributes, thus we're filling ii_NumIndexAttrs and
187+
* ii_NumIndexKeyAttrs with same value.
186188
*/
187189
indexInfo=makeNode(IndexInfo);
190+
indexInfo->ii_NumIndexAttrs=numberOfAttributes;
191+
indexInfo->ii_NumIndexKeyAttrs=numberOfAttributes;
188192
indexInfo->ii_Expressions=NIL;
189193
indexInfo->ii_ExpressionsState=NIL;
190194
indexInfo->ii_PredicateState=NULL;
@@ -650,7 +654,7 @@ DefineIndex(Oid relationId,
650654

651655
typeObjectId= (Oid*)palloc(numberOfAttributes*sizeof(Oid));
652656
collationObjectId= (Oid*)palloc(numberOfAttributes*sizeof(Oid));
653-
classObjectId= (Oid*)palloc(numberOfKeyAttributes*sizeof(Oid));
657+
classObjectId= (Oid*)palloc(numberOfAttributes*sizeof(Oid));
654658
coloptions= (int16*)palloc(numberOfAttributes*sizeof(int16));
655659
ComputeIndexAttrs(indexInfo,
656660
typeObjectId,collationObjectId,classObjectId,
@@ -1518,10 +1522,11 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
15181522
collationOidP[attn]=attcollation;
15191523

15201524
/*
1521-
*Skipopclass and ordering options for included columns.
1525+
*Included columns have noopclass andnoordering options.
15221526
*/
15231527
if (attn >=nkeycols)
15241528
{
1529+
classOidP[attn]=InvalidOid;
15251530
colOptionP[attn]=0;
15261531
attn++;
15271532
continue;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp