From 573a71a5da70d6e2503c8f53e3b4f26b3b6d738d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 1 Jul 2004 00:52:04 +0000 Subject: Nested transactions. There is still much left to do, especially on the performance front, but with feature freeze upon us I think it's time to drive a stake in the ground and say that this will be in 7.5. Alvaro Herrera, with some help from Tom Lane. --- src/backend/access/gist/gistscan.c | 44 +++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'src/backend/access/gist') 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) { -- cgit v1.2.3