aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/gist/gistscan.c
diff options
context:
space:
mode:
authorTeodor Sigaev <teodor@sigaev.ru>2008-08-23 10:43:58 +0000
committerTeodor Sigaev <teodor@sigaev.ru>2008-08-23 10:43:58 +0000
commit4040629fe13c18630768fc3c5ff84b3ff3a32fdf (patch)
tree48b3fc202e92dcd0b07dd480ee9b0b736d00dd3f /src/backend/access/gist/gistscan.c
parent7e9308544f041cf59e0dd4916fe93fee9aa91f99 (diff)
downloadpostgresql-4040629fe13c18630768fc3c5ff84b3ff3a32fdf.tar.gz
postgresql-4040629fe13c18630768fc3c5ff84b3ff3a32fdf.zip
Fix possible duplicate tuples while GiST scan. Now page is processed
at once and ItemPointers are collected in memory. Remove tuple's killing by killtuple() if tuple was moved to another page - it could produce unaceptable overhead. Backpatch up to 8.1 because the bug was introduced by GiST's concurrency support.
Diffstat (limited to 'src/backend/access/gist/gistscan.c')
-rw-r--r--src/backend/access/gist/gistscan.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/backend/access/gist/gistscan.c b/src/backend/access/gist/gistscan.c
index 97f4d264d1a..3604debba0f 100644
--- a/src/backend/access/gist/gistscan.c
+++ b/src/backend/access/gist/gistscan.c
@@ -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 2005/09/22 20:44:36 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.61.2.1 2008/08/23 10:43:58 teodor Exp $
*
*-------------------------------------------------------------------------
*/
@@ -98,6 +98,7 @@ gistrescan(PG_FUNCTION_ARGS)
ReleaseBuffer(so->markbuf);
so->markbuf = InvalidBuffer;
}
+
}
else
{
@@ -113,6 +114,8 @@ gistrescan(PG_FUNCTION_ARGS)
scan->opaque = so;
}
+ so->nPageData = so->curPageData = 0;
+
/* Update scan key, if a new one is given */
if (key && scan->numberOfKeys > 0)
{
@@ -179,6 +182,11 @@ gistmarkpos(PG_FUNCTION_ARGS)
so->markbuf = so->curbuf;
}
+ so->markNPageData = so->nPageData;
+ so->markCurPageData = so->curPageData;
+ if ( so->markNPageData > 0 )
+ memcpy( so->markPageData, so->pageData, sizeof(ItemPointerData) * so->markNPageData );
+
PG_RETURN_VOID();
}
@@ -228,6 +236,11 @@ gistrestrpos(PG_FUNCTION_ARGS)
so->curbuf = so->markbuf;
}
+ so->nPageData = so->markNPageData;
+ so->curPageData = so->markNPageData;
+ if ( so->markNPageData > 0 )
+ memcpy( so->pageData, so->markPageData, sizeof(ItemPointerData) * so->markNPageData );
+
PG_RETURN_VOID();
}