postgres.git / summary / log / commit / refs

commit    37edecfdfe21c2d20431109e9d1aeb18485bbf0a
Author:   Simon Riggs <simon@2ndQuadrant.com>
Date:     Sat May 12 12:24:15 2012 +0000
First released in: 9.2.0, 9.0.8, 9.1.4

    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 df790c0693e..d1cebeb86db 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -386,11 +386,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 @@ -399,13 +398,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; } [parent: 329ee80f79b4]