mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Replace nested-BEGIN syntax for subtransactions with spec-compliant
SAVEPOINT/RELEASE/ROLLBACK-TO syntax. (Alvaro) Cause COMMIT of a failed transaction to report ROLLBACK instead of COMMIT in its command tag. (Tom) Fix a few loose ends in the nested-transactions stuff.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lmgr.c,v 1.64 2004/07/01 00:50:59 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lmgr.c,v 1.65 2004/07/27 05:10:58 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -334,21 +334,23 @@ XactLockTableInsert(TransactionId xid)
|
||||
* XactLockTableWait
|
||||
*
|
||||
* Wait for the specified transaction to commit or abort.
|
||||
* We actually wait on the topmost transaction of the transaction tree.
|
||||
*
|
||||
* Note that this does the right thing for subtransactions: if we
|
||||
* wait on a subtransaction, we will be awakened as soon as it aborts
|
||||
* or its parent commits.
|
||||
*/
|
||||
void
|
||||
XactLockTableWait(TransactionId xid)
|
||||
{
|
||||
LOCKTAG tag;
|
||||
TransactionId myxid = GetCurrentTransactionId();
|
||||
TransactionId waitXid = SubTransGetTopmostTransaction(xid);
|
||||
|
||||
Assert(!SubTransXidsHaveCommonAncestor(waitXid, myxid));
|
||||
Assert(!SubTransXidsHaveCommonAncestor(xid, myxid));
|
||||
|
||||
MemSet(&tag, 0, sizeof(tag));
|
||||
tag.relId = XactLockTableId;
|
||||
tag.dbId = InvalidOid;
|
||||
tag.objId.xid = waitXid;
|
||||
tag.objId.xid = xid;
|
||||
|
||||
if (!LockAcquire(LockTableId, &tag, myxid,
|
||||
ShareLock, false))
|
||||
@@ -358,13 +360,8 @@ XactLockTableWait(TransactionId xid)
|
||||
|
||||
/*
|
||||
* Transaction was committed/aborted/crashed - we have to update
|
||||
* pg_clog if transaction is still marked as running. If it's a
|
||||
* subtransaction, we can update the parent status too.
|
||||
* pg_clog if transaction is still marked as running.
|
||||
*/
|
||||
if (!TransactionIdDidCommit(waitXid) && !TransactionIdDidAbort(waitXid))
|
||||
{
|
||||
TransactionIdAbort(waitXid);
|
||||
if (waitXid != xid)
|
||||
TransactionIdAbort(xid);
|
||||
}
|
||||
if (!TransactionIdDidCommit(xid) && !TransactionIdDidAbort(xid))
|
||||
TransactionIdAbort(xid);
|
||||
}
|
||||
|
Reference in New Issue
Block a user