Skip to content

Commit 867540b

Browse files
Ensure backwards compatibility for GetStableLatestTransactionId()
1 parent afe86a9 commit 867540b

File tree

1 file changed

+8
-6
lines changed
  • src/backend/access/transam

1 file changed

+8
-6
lines changed

src/backend/access/transam/xact.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,10 @@ GetCurrentTransactionIdIfAny(void)
390390
return CurrentTransactionState->transactionId;
391391
}
392392

393-
394393
/*
395-
* GetStableLatestTransactionIdIfAny
394+
* GetStableLatestTransactionId
396395
*
397-
* Get the latest XID once and then return same value for rest of transaction.
396+
* Get the XID once and then return same value for rest of transaction.
398397
* Acts as a useful reference point for maintenance tasks.
399398
*/
400399
TransactionId
@@ -403,13 +402,16 @@ GetStableLatestTransactionId(void)
403402
static LocalTransactionId lxid = InvalidLocalTransactionId;
404403
static TransactionId stablexid = InvalidTransactionId;
405404

406-
if (lxid != MyProc->lxid ||
407-
!TransactionIdIsValid(stablexid))
405+
if (lxid != MyProc->lxid)
408406
{
409407
lxid = MyProc->lxid;
410-
stablexid = ReadNewTransactionId();
408+
stablexid = GetTopTransactionIdIfAny();
409+
if (!TransactionIdIsValid(stablexid))
410+
stablexid = ReadNewTransactionId();
411411
}
412412

413+
Assert(TransactionIdIsValid(stablexid));
414+
413415
return stablexid;
414416
}
415417

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy