diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-07-01 00:52:04 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-07-01 00:52:04 +0000 |
commit | 573a71a5da70d6e2503c8f53e3b4f26b3b6d738d (patch) | |
tree | 070f677b0043631518f83ce84ff201bf8fda700f /src/backend/access/transam/varsup.c | |
parent | 4c9aa572fa2ee60e8ac557b866eccc7310df0a09 (diff) |
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.
Diffstat (limited to 'src/backend/access/transam/varsup.c')
-rw-r--r-- | src/backend/access/transam/varsup.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c index 617c7d19c43..9d3b0b323aa 100644 --- a/src/backend/access/transam/varsup.c +++ b/src/backend/access/transam/varsup.c @@ -6,7 +6,7 @@ * Copyright (c) 2000-2003, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.55 2004/01/26 19:15:59 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.56 2004/07/01 00:49:42 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -14,6 +14,7 @@ #include "postgres.h" #include "access/clog.h" +#include "access/subtrans.h" #include "access/transam.h" #include "storage/ipc.h" #include "storage/proc.h" @@ -30,7 +31,7 @@ VariableCache ShmemVariableCache = NULL; * Allocate the next XID for my new transaction. */ TransactionId -GetNewTransactionId(void) +GetNewTransactionId(bool isSubXact) { TransactionId xid; @@ -52,8 +53,11 @@ GetNewTransactionId(void) * commit a later XID before we zero the page. Fortunately, a page of * the commit log holds 32K or more transactions, so we don't have to * do this very often. + * + * Extend pg_subtrans too. */ ExtendCLOG(xid); + ExtendSUBTRANS(xid); /* * Now advance the nextXid counter. This must not happen until after @@ -82,8 +86,11 @@ GetNewTransactionId(void) * its own spinlock used only for fetching/storing that PGPROC's xid. * (SInvalLock would then mean primarily that PGPROCs couldn't be added/ * removed while holding the lock.) + * + * We don't want a subtransaction to update the stored Xid; we'll check + * if a transaction Xid is a running subxact by checking pg_subtrans. */ - if (MyProc != NULL) + if (MyProc != NULL && !isSubXact) MyProc->xid = xid; LWLockRelease(XidGenLock); |