From a8d1075f271458960da683e8ec28f5a656984159 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 18 Jun 2005 19:33:42 +0000 Subject: 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. --- src/backend/access/transam/xact.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/backend/access/transam/xact.c') 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; /* -- cgit v1.2.3