aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2012-05-12 13:26:10 +0100
committerSimon Riggs <simon@2ndQuadrant.com>2012-05-12 13:26:10 +0100
commit867540b49cd248ea867cfcf04d3dbb2ba4f506b8 (patch)
treec42a15cd355cf92ea77bc7984c227b356413ff6c
parentafe86a9e73b0d30f34dfdc196a6b52ce1306a95e (diff)
downloadpostgresql-867540b49cd248ea867cfcf04d3dbb2ba4f506b8.tar.gz
postgresql-867540b49cd248ea867cfcf04d3dbb2ba4f506b8.zip
Ensure backwards compatibility for GetStableLatestTransactionId()
-rw-r--r--src/backend/access/transam/xact.c14
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;
}