mirror of
https://github.com/postgres/postgres.git
synced 2025-08-18 12:22:09 +03:00
Fix GiST's killing tuple: GISTScanOpaque->curpos wasn't
correctly set. As result, killtuple() marks as dead wrong tuple on page. Bug was introduced by me while fixing possible duplicates during GiST index scan.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.52.2.2 2008/08/23 10:43:58 teodor Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.52.2.3 2008/10/22 12:56:25 teodor Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -153,7 +153,11 @@ gistnext(IndexScanDesc scan, ScanDirection dir, ItemPointer tids, int maxtids, b
|
||||
{
|
||||
while( ntids < maxtids && so->curPageData < so->nPageData )
|
||||
{
|
||||
tids[ ntids ] = scan->xs_ctup.t_self = so->pageData[ so->curPageData ];
|
||||
tids[ ntids ] = scan->xs_ctup.t_self = so->pageData[ so->curPageData ].heapPtr;
|
||||
ItemPointerSet(&scan->currentItemData,
|
||||
BufferGetBlockNumber(so->curbuf),
|
||||
so->pageData[ so->curPageData ].pageOffset);
|
||||
|
||||
|
||||
so->curPageData ++;
|
||||
ntids++;
|
||||
@@ -246,8 +250,13 @@ gistnext(IndexScanDesc scan, ScanDirection dir, ItemPointer tids, int maxtids, b
|
||||
{
|
||||
while( ntids < maxtids && so->curPageData < so->nPageData )
|
||||
{
|
||||
tids[ ntids ] = scan->xs_ctup.t_self = so->pageData[ so->curPageData ];
|
||||
tids[ ntids ] = scan->xs_ctup.t_self =
|
||||
so->pageData[ so->curPageData ].heapPtr;
|
||||
|
||||
ItemPointerSet(&scan->currentItemData,
|
||||
BufferGetBlockNumber(so->curbuf),
|
||||
so->pageData[ so->curPageData ].pageOffset);
|
||||
|
||||
so->curPageData ++;
|
||||
ntids++;
|
||||
}
|
||||
@@ -291,13 +300,11 @@ gistnext(IndexScanDesc scan, ScanDirection dir, ItemPointer tids, int maxtids, b
|
||||
* we can efficiently resume the index scan later.
|
||||
*/
|
||||
|
||||
ItemPointerSet(&(scan->currentItemData),
|
||||
BufferGetBlockNumber(so->curbuf), n);
|
||||
|
||||
if (!(ignore_killed_tuples && ItemIdDeleted(PageGetItemId(p, n))))
|
||||
{
|
||||
it = (IndexTuple) PageGetItem(p, PageGetItemId(p, n));
|
||||
so->pageData[ so->nPageData ] = it->t_tid;
|
||||
so->pageData[ so->nPageData ].heapPtr = it->t_tid;
|
||||
so->pageData[ so->nPageData ].pageOffset = n;
|
||||
so->nPageData ++;
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.61.2.1 2008/08/23 10:43:58 teodor Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.61.2.2 2008/10/22 12:56:25 teodor Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -185,7 +185,7 @@ gistmarkpos(PG_FUNCTION_ARGS)
|
||||
so->markNPageData = so->nPageData;
|
||||
so->markCurPageData = so->curPageData;
|
||||
if ( so->markNPageData > 0 )
|
||||
memcpy( so->markPageData, so->pageData, sizeof(ItemPointerData) * so->markNPageData );
|
||||
memcpy( so->markPageData, so->pageData, sizeof(MatchedItemPtr) * so->markNPageData );
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
@@ -239,7 +239,7 @@ gistrestrpos(PG_FUNCTION_ARGS)
|
||||
so->nPageData = so->markNPageData;
|
||||
so->curPageData = so->markNPageData;
|
||||
if ( so->markNPageData > 0 )
|
||||
memcpy( so->pageData, so->markPageData, sizeof(ItemPointerData) * so->markNPageData );
|
||||
memcpy( so->pageData, so->markPageData, sizeof(MatchedItemPtr) * so->markNPageData );
|
||||
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
Reference in New Issue
Block a user