From 867540b49cd248ea867cfcf04d3dbb2ba4f506b8 Mon Sep 17 00:00:00 2001 From: Simon Riggs Date: Sat, 12 May 2012 13:26:10 +0100 Subject: [PATCH] Ensure backwards compatibility for GetStableLatestTransactionId() --- src/backend/access/transam/xact.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 1654a0e5c7..c71a10e4ea 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -390,11 +390,10 @@ GetCurrentTransactionIdIfAny(void) return CurrentTransactionState->transactionId; } - /* - * GetStableLatestTransactionIdIfAny + * GetStableLatestTransactionId * - * Get the latest XID once and then return same value for rest of transaction. + * Get the XID once and then return same value for rest of transaction. * Acts as a useful reference point for maintenance tasks. */ TransactionId @@ -403,13 +402,16 @@ GetStableLatestTransactionId(void) static LocalTransactionId lxid = InvalidLocalTransactionId; static TransactionId stablexid = InvalidTransactionId; - if (lxid != MyProc->lxid || - !TransactionIdIsValid(stablexid)) + if (lxid != MyProc->lxid) { lxid = MyProc->lxid; - stablexid = ReadNewTransactionId(); + stablexid = GetTopTransactionIdIfAny(); + if (!TransactionIdIsValid(stablexid)) + stablexid = ReadNewTransactionId(); } + Assert(TransactionIdIsValid(stablexid)); + return stablexid; } -- 2.40.0