File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
src/backend/access/transam Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff 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 */
400399TransactionId
@@ -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
You can’t perform that action at this time.
0 commit comments