diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-06-18 19:33:42 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-06-18 19:33:42 +0000 |
commit | a8d1075f271458960da683e8ec28f5a656984159 (patch) | |
tree | ef8741a8a574283dc2bba0b9691b84ab12552839 /src/backend/access/transam/xact.c | |
parent | 66b098492e62667bd20e8745de7bde9d00851147 (diff) |
Add a time-of-preparation column to the pg_prepared_xacts view, per an
old suggestion by Oliver Jowett. Also, add a transaction column to the
pg_locks view to show the xid of each transaction holding or awaiting
locks; this allows prepared transactions to be properly associated with
the locks they own. There was already a column named 'transaction',
and I chose to rename it to 'transactionid' --- since this column is
new in the current devel cycle there should be no backwards compatibility
issue to worry about.
Diffstat (limited to 'src/backend/access/transam/xact.c')
-rw-r--r-- | src/backend/access/transam/xact.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 74163b7f576..2f73ee10c06 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.205 2005/06/17 22:32:42 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.206 2005/06/18 19:33:41 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1630,6 +1630,9 @@ PrepareTransaction(void) TransactionState s = CurrentTransactionState; TransactionId xid = GetCurrentTransactionId(); GlobalTransaction gxact; + TimestampTz prepared_at; + AbsoluteTime PreparedSec; /* integer part */ + int PreparedUSec; /* microsecond part */ ShowTransactionState("PrepareTransaction"); @@ -1692,6 +1695,9 @@ PrepareTransaction(void) */ s->state = TRANS_PREPARE; + PreparedSec = GetCurrentAbsoluteTimeUsec(&PreparedUSec); + prepared_at = AbsoluteTimeUsecToTimestampTz(PreparedSec, PreparedUSec); + /* Tell bufmgr and smgr to prepare for commit */ BufmgrCommit(); @@ -1699,7 +1705,8 @@ PrepareTransaction(void) * Reserve the GID for this transaction. This could fail if the * requested GID is invalid or already in use. */ - gxact = MarkAsPreparing(xid, MyDatabaseId, prepareGID, GetUserId()); + gxact = MarkAsPreparing(xid, prepareGID, prepared_at, + GetUserId(), MyDatabaseId); prepareGID = NULL; /* |