diff options
Diffstat (limited to 'src/backend/access/gist/gistscan.c')
-rw-r--r-- | src/backend/access/gist/gistscan.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/backend/access/gist/gistscan.c b/src/backend/access/gist/gistscan.c index 30bb9b810af..dc424a6773d 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.51 2004/01/07 18:56:23 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.52 2004/07/01 00:49:27 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -41,6 +41,7 @@ static void adjustiptr(IndexScanDesc s, ItemPointer iptr, typedef struct GISTScanListData { IndexScanDesc gsl_scan; + TransactionId gsl_creatingXid; struct GISTScanListData *gsl_next; } GISTScanListData; @@ -223,6 +224,7 @@ gistregscan(IndexScanDesc s) l = (GISTScanList) palloc(sizeof(GISTScanListData)); l->gsl_scan = s; + l->gsl_creatingXid = GetCurrentTransactionId(); l->gsl_next = GISTScans; GISTScans = l; } @@ -271,6 +273,46 @@ AtEOXact_gist(void) GISTScans = NULL; } +/* + * AtEOSubXact_gist() --- clean up gist subsystem at subxact abort or commit. + * + * This is here because it needs to touch this module's static var GISTScans. + */ +void +AtEOSubXact_gist(TransactionId childXid) +{ + GISTScanList l; + GISTScanList prev; + GISTScanList next; + + /* + * Note: these actions should only be necessary during xact abort; but + * they can't hurt during a commit. + */ + + /* + * Forget active scans that were started in this subtransaction. + */ + prev = NULL; + + for (l = GISTScans; l != NULL; l = next) + { + next = l->gsl_next; + if (l->gsl_creatingXid == childXid) + { + if (prev == NULL) + GISTScans = next; + else + prev->gsl_next = next; + + pfree(l); + /* prev does not change */ + } + else + prev = l; + } +} + void gistadjscans(Relation rel, int op, BlockNumber blkno, OffsetNumber offnum) { |