summaryrefslogtreecommitdiff
path: root/src/backend/access/transam/varsup.c
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2019-03-28 10:59:19 +1300
committerThomas Munro <tmunro@postgresql.org>2019-03-28 18:24:43 +1300
commitad308058cc8666c50b43179e64d6bb7aeb3ba169 (patch)
treebf8c6e0f7d056eba1fa182e26c53dda7e0e72377 /src/backend/access/transam/varsup.c
parent2fc7af5e966043a412e8e69c135fae55a2db6d4f (diff)
Use FullTransactionId for the transaction stack.
Provide GetTopFullTransactionId() and GetCurrentFullTransactionId(). The intended users of these interfaces are access methods that use xids for visibility checks but don't want to have to go back and "freeze" existing references some time later before the 32 bit xid counter wraps around. Use a new struct to serialize the transaction state for parallel query, because FullTransactionId doesn't fit into the previous serialization scheme very well. Author: Thomas Munro Reviewed-by: Heikki Linnakangas Discussion: https://postgr.es/m/CAA4eK1%2BMv%2Bmb0HFfWM9Srtc6MVe160WFurXV68iAFMcagRZ0dQ%40mail.gmail.com
Diffstat (limited to 'src/backend/access/transam/varsup.c')
-rw-r--r--src/backend/access/transam/varsup.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c
index efe18d3d3fb..8c3d84fbf23 100644
--- a/src/backend/access/transam/varsup.c
+++ b/src/backend/access/transam/varsup.c
@@ -35,7 +35,8 @@ VariableCache ShmemVariableCache = NULL;
/*
- * Allocate the next XID for a new transaction or subtransaction.
+ * Allocate the next FullTransactionId for a new transaction or
+ * subtransaction.
*
* The new XID is also stored into MyPgXact before returning.
*
@@ -44,9 +45,10 @@ VariableCache ShmemVariableCache = NULL;
* does something. So it is safe to do a database lookup if we want to
* issue a warning about XID wrap.
*/
-TransactionId
+FullTransactionId
GetNewTransactionId(bool isSubXact)
{
+ FullTransactionId full_xid;
TransactionId xid;
/*
@@ -64,7 +66,7 @@ GetNewTransactionId(bool isSubXact)
{
Assert(!isSubXact);
MyPgXact->xid = BootstrapTransactionId;
- return BootstrapTransactionId;
+ return FullTransactionIdFromEpochAndXid(0, BootstrapTransactionId);
}
/* safety check, we should never get this far in a HS standby */
@@ -73,7 +75,8 @@ GetNewTransactionId(bool isSubXact)
LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
- xid = XidFromFullTransactionId(ShmemVariableCache->nextFullXid);
+ full_xid = ShmemVariableCache->nextFullXid;
+ xid = XidFromFullTransactionId(full_xid);
/*----------
* Check to see if it's safe to assign another XID. This protects against
@@ -232,7 +235,7 @@ GetNewTransactionId(bool isSubXact)
LWLockRelease(XidGenLock);
- return xid;
+ return full_xid;
}
/*