1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-18 17:42:25 +03:00

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.
This commit is contained in:
Tom Lane
2005-06-18 19:33:42 +00:00
parent 66b098492e
commit a8d1075f27
8 changed files with 106 additions and 54 deletions

View File

@ -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;
/*