Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 39c2915

Browse files
committed
Refactoring of visibility functions for global temp table tuples
1 parent ceaf5e0 commit 39c2915

File tree

3 files changed

+13
-20
lines changed

3 files changed

+13
-20
lines changed

src/backend/access/heap/heapam_handler.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ heapam_tuple_satisfies_snapshot(Relation rel, TupleTableSlot *slot,
226226
* Caller should be holding pin, but not lock.
227227
*/
228228
LockBuffer(bslot->buffer, BUFFER_LOCK_SHARE);
229-
229+
230230
res = HeapTupleSatisfiesVisibility(rel, bslot->base.tuple, snapshot,
231231
bslot->buffer);
232232
LockBuffer(bslot->buffer, BUFFER_LOCK_UNLOCK);

src/backend/access/heap/heapam_visibility.c

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,7 +1682,7 @@ HeapTupleSatisfiesHistoricMVCC(HeapTuple htup, Snapshot snapshot,
16821682

16831683
/*
16841684
* TempTupleSatisfiesVisibility
1685-
* True iff global temp table tuple is visible for the given snapshot.
1685+
* True iff global temp table tuple is visible for the current transaction.
16861686
*
16871687
* Temporary tables are visible only for current backend, so there is no need to
16881688
* handle cases with tuples committed by other backends. We only need to exclude
@@ -1696,7 +1696,6 @@ TempTupleSatisfiesVisibility(HeapTuple htup, CommandId curcid, Buffer buffer)
16961696
TransactionId xmin;
16971697
TransactionId xmax;
16981698

1699-
17001699
Assert(ItemPointerIsValid(&htup->t_self));
17011700
Assert(htup->t_tableOid != InvalidOid);
17021701

@@ -1720,27 +1719,17 @@ TempTupleSatisfiesVisibility(HeapTuple htup, CommandId curcid, Buffer buffer)
17201719
if (HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask)) /* not deleter */
17211720
return true;
17221721

1723-
if (tuple->t_infomask & HEAP_XMAX_IS_MULTI)
1724-
{
1725-
xmax = HeapTupleGetUpdateXid(tuple);
1726-
1727-
/* updating subtransaction must have aborted */
1728-
if (IsReplicaTransactionAborted(xmax))
1729-
return true;
1722+
xmax = (tuple->t_infomask & HEAP_XMAX_IS_MULTI)
1723+
? HeapTupleGetUpdateXid(tuple)
1724+
: HeapTupleHeaderGetRawXmax(tuple);
17301725

1731-
return (HeapTupleHeaderGetCmax(tuple) >= curcid);
1732-
}
1733-
xmax = HeapTupleHeaderGetRawXmax(tuple);
1734-
1735-
/* deleting subtransaction must have aborted */
17361726
if (IsReplicaTransactionAborted(xmax))
1737-
return true;
1727+
return true; /* updating subtransaction aborted */
17381728

1739-
if (IsReplicaCurrentTransactionId(xmax))
1740-
return (HeapTupleHeaderGetCmax(tuple) >= curcid); /* deleted after scan started */
1729+
if (!IsReplicaCurrentTransactionId(xmax))
1730+
return false; /* updating transaction committed */
17411731

1742-
/* xmax transaction committed */
1743-
return false;
1732+
return (HeapTupleHeaderGetCmax(tuple) >= curcid); /* updated after scan started */
17441733
}
17451734

17461735

src/backend/access/transam/varsup.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ GetNewTransactionId(bool isSubXact)
6969
return FullTransactionIdFromEpochAndXid(0, BootstrapTransactionId);
7070
}
7171

72+
/* safety check, we should never get this far in a HS standby */
73+
if (RecoveryInProgress())
74+
elog(ERROR, "cannot assign TransactionIds during recovery");
75+
7276
LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
7377

7478
full_xid = ShmemVariableCache->nextFullXid;

0 commit comments

Comments
 (0)