aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2012-05-12 13:25:34 +0100
committerSimon Riggs <simon@2ndQuadrant.com>2012-05-12 13:25:34 +0100
commit436af241c88a2f9b971dbe248e6ec6360438033c (patch)
tree0ab6eb8bdb1c0c07d744d1b5a8e640c4c1b5e726
parent2c1382d96c575a79a2ce014dda90fd1de78b3612 (diff)
downloadpostgresql-436af241c88a2f9b971dbe248e6ec6360438033c.tar.gz
postgresql-436af241c88a2f9b971dbe248e6ec6360438033c.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 be4905181e0..b34b418fd98 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -392,11 +392,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
@@ -405,13 +404,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;
}