diff options
author | Simon Riggs <simon@2ndQuadrant.com> | 2012-05-12 13:26:10 +0100 |
---|---|---|
committer | Simon Riggs <simon@2ndQuadrant.com> | 2012-05-12 13:26:10 +0100 |
commit | 867540b49cd248ea867cfcf04d3dbb2ba4f506b8 (patch) | |
tree | c42a15cd355cf92ea77bc7984c227b356413ff6c /src/backend/access/transam/xact.c | |
parent | afe86a9e73b0d30f34dfdc196a6b52ce1306a95e (diff) | |
download | postgresql-867540b49cd248ea867cfcf04d3dbb2ba4f506b8.tar.gz postgresql-867540b49cd248ea867cfcf04d3dbb2ba4f506b8.zip |
Ensure backwards compatibility for GetStableLatestTransactionId()
Diffstat (limited to 'src/backend/access/transam/xact.c')
-rw-r--r-- | src/backend/access/transam/xact.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 1654a0e5c73..c71a10e4ea2 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; } |