mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
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.
This commit is contained in:
@@ -8,13 +8,14 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lmgr.c,v 1.63 2004/05/28 05:13:04 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lmgr.c,v 1.64 2004/07/01 00:50:59 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#include "access/subtrans.h"
|
||||
#include "access/transam.h"
|
||||
#include "access/xact.h"
|
||||
#include "catalog/catalog.h"
|
||||
@@ -333,19 +334,21 @@ XactLockTableInsert(TransactionId xid)
|
||||
* XactLockTableWait
|
||||
*
|
||||
* Wait for the specified transaction to commit or abort.
|
||||
* We actually wait on the topmost transaction of the transaction tree.
|
||||
*/
|
||||
void
|
||||
XactLockTableWait(TransactionId xid)
|
||||
{
|
||||
LOCKTAG tag;
|
||||
TransactionId myxid = GetCurrentTransactionId();
|
||||
TransactionId waitXid = SubTransGetTopmostTransaction(xid);
|
||||
|
||||
Assert(!TransactionIdEquals(xid, myxid));
|
||||
Assert(!SubTransXidsHaveCommonAncestor(waitXid, myxid));
|
||||
|
||||
MemSet(&tag, 0, sizeof(tag));
|
||||
tag.relId = XactLockTableId;
|
||||
tag.dbId = InvalidOid;
|
||||
tag.objId.xid = xid;
|
||||
tag.objId.xid = waitXid;
|
||||
|
||||
if (!LockAcquire(LockTableId, &tag, myxid,
|
||||
ShareLock, false))
|
||||
@@ -355,8 +358,13 @@ XactLockTableWait(TransactionId xid)
|
||||
|
||||
/*
|
||||
* Transaction was committed/aborted/crashed - we have to update
|
||||
* pg_clog if transaction is still marked as running.
|
||||
* pg_clog if transaction is still marked as running. If it's a
|
||||
* subtransaction, we can update the parent status too.
|
||||
*/
|
||||
if (!TransactionIdDidCommit(xid) && !TransactionIdDidAbort(xid))
|
||||
TransactionIdAbort(xid);
|
||||
if (!TransactionIdDidCommit(waitXid) && !TransactionIdDidAbort(waitXid))
|
||||
{
|
||||
TransactionIdAbort(waitXid);
|
||||
if (waitXid != xid)
|
||||
TransactionIdAbort(xid);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user