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

Commitb9856b6

Browse files
committed
Fix GiST's killing tuple: GISTScanOpaque->curpos wasn't
correctly set. As result, killtuple() marks as deadwrong tuple on page. Bug was introduced by me while fixingpossible duplicates during GiST index scan.
1 parent361bfc3 commitb9856b6

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed

‎src/backend/access/gist/gistget.c

Lines changed: 27 additions & 19 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/gist/gistget.c,v 1.78 2008/10/20 16:35:14 teodor Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.79 2008/10/22 12:53:56 teodor Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -51,7 +51,7 @@ killtuple(Relation r, GISTScanOpaque so, ItemPointer iptr)
5151

5252
for (offset=FirstOffsetNumber;offset <=maxoff;offset=OffsetNumberNext(offset))
5353
{
54-
IndexTupleituple= (IndexTuple)PageGetItem(p,PageGetItemId(p,offset));
54+
IndexTupleituple= (IndexTuple)PageGetItem(p,PageGetItemId(p,offset));
5555

5656
if (ItemPointerEquals(&(ituple->t_tid),iptr))
5757
{
@@ -139,24 +139,28 @@ gistnext(IndexScanDesc scan, TIDBitmap *tbm)
139139
if (so->qual_ok== false )
140140
return0;
141141

142-
if (ItemPointerIsValid(&so->curpos)==false)
142+
if (so->curbuf==InvalidBuffer )
143143
{
144-
/* Being asked to fetch the first entry, so start at the root */
145-
Assert(so->curbuf==InvalidBuffer);
146-
Assert(so->stack==NULL);
144+
if (ItemPointerIsValid(&so->curpos)== false)
145+
{
146+
/* Being asked to fetch the first entry, so start at the root */
147+
Assert(so->curbuf==InvalidBuffer);
148+
Assert(so->stack==NULL);
147149

148-
so->curbuf=ReadBuffer(scan->indexRelation,GIST_ROOT_BLKNO);
150+
so->curbuf=ReadBuffer(scan->indexRelation,GIST_ROOT_BLKNO);
149151

150-
stk=so->stack= (GISTSearchStack*)palloc0(sizeof(GISTSearchStack));
152+
stk=so->stack= (GISTSearchStack*)palloc0(sizeof(GISTSearchStack));
151153

152-
stk->next=NULL;
153-
stk->block=GIST_ROOT_BLKNO;
154+
stk->next=NULL;
155+
stk->block=GIST_ROOT_BLKNO;
154156

155-
pgstat_count_index_scan(scan->indexRelation);
156-
}
157-
elseif (so->curbuf==InvalidBuffer)
158-
{
159-
return0;
157+
pgstat_count_index_scan(scan->indexRelation);
158+
}
159+
else
160+
{
161+
/* scan is finished */
162+
return0;
163+
}
160164
}
161165

162166
/*
@@ -171,8 +175,13 @@ gistnext(IndexScanDesc scan, TIDBitmap *tbm)
171175

172176
if (so->curPageData<so->nPageData )
173177
{
174-
scan->xs_ctup.t_self=so->pageData[so->curPageData ].iptr;
178+
scan->xs_ctup.t_self=so->pageData[so->curPageData ].heapPtr;
175179
scan->xs_recheck=so->pageData[so->curPageData ].recheck;
180+
181+
ItemPointerSet(&so->curpos,
182+
BufferGetBlockNumber(so->curbuf),
183+
so->pageData[so->curPageData ].pageOffset);
184+
176185
so->curPageData++;
177186

178187
return1;
@@ -307,8 +316,6 @@ gistnext(IndexScanDesc scan, TIDBitmap *tbm)
307316
* return success. Note that we keep "curbuf" pinned so that
308317
* we can efficiently resume the index scan later.
309318
*/
310-
ItemPointerSet(&(so->curpos),
311-
BufferGetBlockNumber(so->curbuf),n);
312319

313320
if (!(scan->ignore_killed_tuples&&
314321
ItemIdIsDead(PageGetItemId(p,n))))
@@ -319,7 +326,8 @@ gistnext(IndexScanDesc scan, TIDBitmap *tbm)
319326
tbm_add_tuples(tbm,&it->t_tid,1,scan->xs_recheck);
320327
else
321328
{
322-
so->pageData[so->nPageData ].iptr=it->t_tid;
329+
so->pageData[so->nPageData ].heapPtr=it->t_tid;
330+
so->pageData[so->nPageData ].pageOffset=n;
323331
so->pageData[so->nPageData ].recheck=scan->xs_recheck;
324332
so->nPageData++;
325333
}

‎src/include/access/gist_private.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/access/gist_private.h,v 1.34 2008/10/20 13:39:44 teodor Exp $
10+
* $PostgreSQL: pgsql/src/include/access/gist_private.h,v 1.35 2008/10/22 12:53:56 teodor Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -60,7 +60,8 @@ typedef struct GISTSTATE
6060

6161
typedefstructItemResult
6262
{
63-
ItemPointerDataiptr;
63+
ItemPointerDataheapPtr;
64+
OffsetNumberpageOffset;/* offset in index page */
6465
boolrecheck;
6566
}ItemResult;
6667

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp