Back-patch BTScan abort fix into REL6_5.
authorTom Lane <[email protected]>
Sun, 8 Aug 1999 20:24:12 +0000 (20:24 +0000)
committerTom Lane <[email protected]>
Sun, 8 Aug 1999 20:24:12 +0000 (20:24 +0000)
src/backend/access/nbtree/nbtscan.c
src/backend/access/transam/transam.c
src/backend/access/transam/xact.c
src/include/access/nbtree.h

index 4cb3747d49e6cac33b424220d92117eda2953709..e51c95a7f1e09b56e8fd1fea34c39a914b2763f9 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.23.2.1 1999/08/02 05:24:41 scrappy Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.23.2.2 1999/08/08 20:24:10 tgl Exp $
  *
  *
  * NOTES
@@ -43,6 +43,28 @@ static BTScanList BTScans = (BTScanList) NULL;
 
 static void _bt_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno);
 
+/*
+ * AtEOXact_nbtree() --- clean up nbtree subsystem at xact abort or commit.
+ *
+ * This is here because it needs to touch this module's static var BTScans.
+ */
+void
+AtEOXact_nbtree(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.
+    */
+   BTScans = NULL;
+
+   /* If we were building a btree, we ain't anymore. */
+   BuildingBtree = false;
+}
+
 /*
  * _bt_regscan() -- register a new scan.
  */
index 74913dccd3efdda9dcbe89ecce859334f590c7cb..1c0acfb2a765c33b074000c37268800adb9c1628 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.27.2.1 1999/08/02 05:56:46 scrappy Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.27.2.2 1999/08/08 20:24:12 tgl Exp $
  *
  * NOTES
  *   This file contains the high level access-method interface to the
@@ -20,7 +20,6 @@
 
 #include "access/heapam.h"
 #include "catalog/catname.h"
-#include "commands/vacuum.h"
 
 static int RecoveryCheckingEnabled(void);
 static void TransRecover(Relation logRelation);
@@ -83,12 +82,6 @@ int          RecoveryCheckingEnableState = 0;
  */
 extern int OidGenLockId;
 
-/* ----------------
- *     globals that must be reset at abort
- * ----------------
- */
-extern bool BuildingBtree;
-
 
 /* ----------------
  *     recovery checking accessors
@@ -568,11 +561,6 @@ TransactionIdCommit(TransactionId transactionId)
 void
 TransactionIdAbort(TransactionId transactionId)
 {
-   BuildingBtree = false;
-
-   if (VacuumRunning)
-       vc_abort();
-
    if (AMI_OVERRIDE)
        return;
 
index bd01429d3b103a23e70a46201621906bbeec1c8f..7eb40c9ab9c591ce8868926a524094419a83d577 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.42.2.1 1999/08/02 05:56:48 scrappy Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.42.2.2 1999/08/08 20:24:12 tgl Exp $
  *
  * NOTES
  *     Transaction aborts can now occur two ways:
  */
 #include "postgres.h"
 
+#include "access/nbtree.h"
 #include "catalog/heap.h"
 #include "commands/async.h"
 #include "commands/sequence.h"
+#include "commands/vacuum.h"
 #include "libpq/be-fsstubs.h"
 #include "storage/proc.h"
 #include "utils/inval.h"
@@ -952,6 +954,7 @@ CommitTransaction()
    }
 
    RelationPurgeLocalRelation(true);
+   AtEOXact_nbtree();
    AtCommit_Cache();
    AtCommit_Locks();
    AtCommit_Memory();
@@ -1013,9 +1016,12 @@ AbortTransaction()
    AtAbort_Notify();
    CloseSequences();
    AtEOXact_portals();
+   if (VacuumRunning)
+       vc_abort();
    RecordTransactionAbort();
    RelationPurgeLocalRelation(false);
    DestroyNoNameRels();
+   AtEOXact_nbtree();
    AtAbort_Cache();
    AtAbort_Locks();
    AtAbort_Memory();
index b4993ca3d2293c873f7c38918d3015e85d7103c3..7064ddb4ea2648c1cffa1c7dd14c86ea2fc7ada3 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: nbtree.h,v 1.27 1999/05/25 22:04:55 momjian Exp $
+ * $Id: nbtree.h,v 1.27.2.1 1999/08/08 20:24:09 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -255,6 +255,7 @@ extern void btdelete(Relation rel, ItemPointer tid);
 extern void _bt_regscan(IndexScanDesc scan);
 extern void _bt_dropscan(IndexScanDesc scan);
 extern void _bt_adjscans(Relation rel, ItemPointer tid);
+extern void AtEOXact_nbtree(void);
 
 /*
  * prototypes for functions in nbtsearch.c