diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-07-17 03:32:14 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-07-17 03:32:14 +0000 |
commit | fe548629c50b753e96515ba2cfd8a85e8fba10de (patch) | |
tree | e80b54f71cb7868db3f9f9c97bccf4c48859951a /src/backend/access/gist/gistscan.c | |
parent | f4c069ca8fc80640bd1bff510697371ffaf45267 (diff) | |
download | postgresql-fe548629c50b753e96515ba2cfd8a85e8fba10de.tar.gz postgresql-fe548629c50b753e96515ba2cfd8a85e8fba10de.zip |
Invent ResourceOwner mechanism as per my recent proposal, and use it to
keep track of portal-related resources separately from transaction-related
resources. This allows cursors to work in a somewhat sane fashion with
nested transactions. For now, cursor behavior is non-subtransactional,
that is a cursor's state does not roll back if you abort a subtransaction
that fetched from the cursor. We might want to change that later.
Diffstat (limited to 'src/backend/access/gist/gistscan.c')
-rw-r--r-- | src/backend/access/gist/gistscan.c | 43 |
1 files changed, 10 insertions, 33 deletions
diff --git a/src/backend/access/gist/gistscan.c b/src/backend/access/gist/gistscan.c index dc424a6773d..1ac3e78dfe1 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.52 2004/07/01 00:49:27 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.53 2004/07/17 03:27:20 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -17,6 +17,7 @@ #include "access/genam.h" #include "access/gist.h" #include "access/gistscan.h" +#include "utils/resowner.h" /* routines defined and used here */ @@ -41,7 +42,7 @@ static void adjustiptr(IndexScanDesc s, ItemPointer iptr, typedef struct GISTScanListData { IndexScanDesc gsl_scan; - TransactionId gsl_creatingXid; + ResourceOwner gsl_owner; struct GISTScanListData *gsl_next; } GISTScanListData; @@ -224,7 +225,7 @@ gistregscan(IndexScanDesc s) l = (GISTScanList) palloc(sizeof(GISTScanListData)); l->gsl_scan = s; - l->gsl_creatingXid = GetCurrentTransactionId(); + l->gsl_owner = CurrentResourceOwner; l->gsl_next = GISTScans; GISTScans = l; } @@ -253,52 +254,28 @@ gistdropscan(IndexScanDesc s) } /* - * AtEOXact_gist() --- clean up gist subsystem at xact abort or commit. + * ReleaseResources_gist() --- clean up gist subsystem resources. * * This is here because it needs to touch this module's static var GISTScans. */ void -AtEOXact_gist(void) -{ - /* - * Note: these actions should only be necessary during xact abort; but - * they can't hurt during a commit. - */ - - /* - * Reset the active-scans list to empty. We do not need to free the - * list elements, because they're all palloc()'d, so they'll go away - * at end of transaction anyway. - */ - 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) +ReleaseResources_gist(void) { 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. + * Note: this should be a no-op during normal query shutdown. + * However, in an abort situation ExecutorEnd is not called and so + * there may be open index scans to clean up. */ prev = NULL; for (l = GISTScans; l != NULL; l = next) { next = l->gsl_next; - if (l->gsl_creatingXid == childXid) + if (l->gsl_owner == CurrentResourceOwner) { if (prev == NULL) GISTScans = next; |