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

Commit5e75f67

Browse files
committed
Fix multicolumn GIN's wrong results with fastupdate enabled.
User-defined consistent functions believes the check arraycontains at least one true element which was not a true forscanning pending list.Per report from Yury Don <yura@vpcit.ru>
1 parent0894c6b commit5e75f67

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

‎src/backend/access/gin/ginget.c

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
*$PostgreSQL: pgsql/src/backend/access/gin/ginget.c,v 1.27 2009/06/11 14:48:53 momjian Exp $
11+
*$PostgreSQL: pgsql/src/backend/access/gin/ginget.c,v 1.28 2009/11/13 11:17:04 teodor Exp $
1212
*-------------------------------------------------------------------------
1313
*/
1414

@@ -25,10 +25,11 @@
2525

2626
typedefstructpendingPosition
2727
{
28-
BufferpendingBuffer;
29-
OffsetNumberfirstOffset;
30-
OffsetNumberlastOffset;
31-
ItemPointerDataitem;
28+
BufferpendingBuffer;
29+
OffsetNumberfirstOffset;
30+
OffsetNumberlastOffset;
31+
ItemPointerDataitem;
32+
bool*hasMatchKey;
3233
}pendingPosition;
3334

3435

@@ -873,6 +874,18 @@ matchPartialInPendingList(GinState *ginstate, Page page,
873874
return false;
874875
}
875876

877+
staticbool
878+
hasAllMatchingKeys(GinScanOpaqueso,pendingPosition*pos)
879+
{
880+
inti;
881+
882+
for (i=0;i<so->nkeys;i++)
883+
if (pos->hasMatchKey[i]== false)
884+
return false;
885+
886+
return true;
887+
}
888+
876889
/*
877890
* Sets entryRes array for each key by looking at
878891
* every entry per indexed value (heap's row) in pending list.
@@ -889,7 +902,6 @@ collectDatumForItem(IndexScanDesc scan, pendingPosition *pos)
889902
IndexTupleitup;
890903
inti,
891904
j;
892-
boolhasMatch= false;
893905

894906
/*
895907
* Resets entryRes
@@ -900,6 +912,7 @@ collectDatumForItem(IndexScanDesc scan, pendingPosition *pos)
900912

901913
memset(key->entryRes, FALSE,key->nentries);
902914
}
915+
memset(pos->hasMatchKey, FALSE,so->nkeys);
903916

904917
for (;;)
905918
{
@@ -1005,7 +1018,7 @@ collectDatumForItem(IndexScanDesc scan, pendingPosition *pos)
10051018
entry->extra_data);
10061019
}
10071020

1008-
hasMatch |=key->entryRes[j];
1021+
pos->hasMatchKey[i] |=key->entryRes[j];
10091022
}
10101023
}
10111024

@@ -1017,7 +1030,7 @@ collectDatumForItem(IndexScanDesc scan, pendingPosition *pos)
10171030
* We scan all values from one tuple, go to next one
10181031
*/
10191032

1020-
returnhasMatch;
1033+
returnhasAllMatchingKeys(so,pos);
10211034
}
10221035
else
10231036
{
@@ -1034,7 +1047,7 @@ collectDatumForItem(IndexScanDesc scan, pendingPosition *pos)
10341047
}
10351048
}
10361049

1037-
returnhasMatch;
1050+
returnhasAllMatchingKeys(so,pos);
10381051
}
10391052

10401053
/*
@@ -1073,6 +1086,7 @@ scanPendingInsert(IndexScanDesc scan, TIDBitmap *tbm, int64 *ntids)
10731086
LockBuffer(pos.pendingBuffer,GIN_SHARE);
10741087
pos.firstOffset=FirstOffsetNumber;
10751088
UnlockReleaseBuffer(metabuffer);
1089+
pos.hasMatchKey=palloc(sizeof(bool)*so->nkeys);
10761090

10771091
/*
10781092
* loop for each heap row. scanGetCandidate returns full row or row's
@@ -1126,6 +1140,8 @@ scanPendingInsert(IndexScanDesc scan, TIDBitmap *tbm, int64 *ntids)
11261140
(*ntids)++;
11271141
}
11281142
}
1143+
1144+
pfree(pos.hasMatchKey);
11291145
}
11301146

11311147
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp