summaryrefslogtreecommitdiff
path: root/src/include/storage/proc.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-08-01 17:32:22 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-08-01 17:32:22 +0000
commitefcaf1e868d8399d932e68b8b248bcbd089b2d6b (patch)
treec6235945f73faab427498dd8662efab5cf2fe5fd /src/include/storage/proc.h
parent9d9cdf82a404f3e2a2d82cefc2c35ded55bb3b2e (diff)
downloadpostgresql-efcaf1e868d8399d932e68b8b248bcbd089b2d6b.tar.gz
Some mop-up work for savepoints (nested transactions). Store a small
number of active subtransaction XIDs in each backend's PGPROC entry, and use this to avoid expensive probes into pg_subtrans during TransactionIdIsInProgress. Extend EOXactCallback API to allow add-on modules to get control at subxact start/end. (This is deliberately not compatible with the former API, since any uses of that API probably need manual review anyway.) Add basic reference documentation for SAVEPOINT and related commands. Minor other cleanups to check off some of the open issues for subtransactions. Alvaro Herrera and Tom Lane.
Diffstat (limited to 'src/include/storage/proc.h')
-rw-r--r--src/include/storage/proc.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index c2411bef07..4f7f39003a 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.71 2004/07/21 20:34:49 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.72 2004/08/01 17:32:21 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -21,6 +21,25 @@
/*
+ * Each backend advertises up to PGPROC_MAX_CACHED_SUBXIDS TransactionIds
+ * for non-aborted subtransactions of its current top transaction. These
+ * have to be treated as running XIDs by other backends.
+ *
+ * We also keep track of whether the cache overflowed (ie, the transaction has
+ * generated at least one subtransaction that didn't fit in the cache).
+ * If none of the caches have overflowed, we can assume that an XID that's not
+ * listed anywhere in the PGPROC array is not a running transaction. Else we
+ * have to look at pg_subtrans.
+ */
+#define PGPROC_MAX_CACHED_SUBXIDS 64 /* XXX guessed-at value */
+
+struct XidCache {
+ bool overflowed;
+ int nxids;
+ TransactionId xids[PGPROC_MAX_CACHED_SUBXIDS];
+};
+
+/*
* Each backend has a PGPROC struct in shared memory. There is also a list of
* currently-unused PGPROC structs that will be reallocated to new backends.
*
@@ -68,6 +87,8 @@ struct PGPROC
SHM_QUEUE procHolders; /* list of PROCLOCK objects for locks held
* or awaited by this backend */
+
+ struct XidCache subxids; /* cache for subtransaction XIDs */
};
/* NOTE: "typedef struct PGPROC PGPROC" appears in storage/lock.h. */