@@ -444,7 +444,7 @@ heapgetpage(TableScanDesc sscan, BlockNumber page)
444
444
if (all_visible )
445
445
valid = true;
446
446
else
447
- valid = HeapTupleSatisfiesVisibility (& loctup , snapshot , buffer );
447
+ valid = HeapTupleSatisfiesVisibility (scan -> rs_base . rs_rd , & loctup , snapshot , buffer );
448
448
449
449
CheckForSerializableConflictOut (valid , scan -> rs_base .rs_rd ,
450
450
& loctup , buffer , snapshot );
@@ -664,7 +664,8 @@ heapgettup(HeapScanDesc scan,
664
664
/*
665
665
* if current tuple qualifies, return it.
666
666
*/
667
- valid = HeapTupleSatisfiesVisibility (tuple ,
667
+ valid = HeapTupleSatisfiesVisibility (scan -> rs_base .rs_rd ,
668
+ tuple ,
668
669
snapshot ,
669
670
scan -> rs_cbuf );
670
671
@@ -1474,7 +1475,7 @@ heap_fetch(Relation relation,
1474
1475
/*
1475
1476
* check tuple visibility, then release lock
1476
1477
*/
1477
- valid = HeapTupleSatisfiesVisibility (tuple , snapshot , buffer );
1478
+ valid = HeapTupleSatisfiesVisibility (relation , tuple , snapshot , buffer );
1478
1479
1479
1480
if (valid )
1480
1481
PredicateLockTuple (relation , tuple , snapshot );
@@ -1612,7 +1613,7 @@ heap_hot_search_buffer(ItemPointer tid, Relation relation, Buffer buffer,
1612
1613
ItemPointerSet (& (heapTuple -> t_self ), BufferGetBlockNumber (buffer ), offnum );
1613
1614
1614
1615
/* If it's visible per the snapshot, we must return it */
1615
- valid = HeapTupleSatisfiesVisibility (heapTuple , snapshot , buffer );
1616
+ valid = HeapTupleSatisfiesVisibility (relation , heapTuple , snapshot , buffer );
1616
1617
CheckForSerializableConflictOut (valid , relation , heapTuple ,
1617
1618
buffer , snapshot );
1618
1619
/* reset to original, non-redirected, tid */
@@ -1754,7 +1755,7 @@ heap_get_latest_tid(TableScanDesc sscan,
1754
1755
* Check tuple visibility; if visible, set it as the new result
1755
1756
* candidate.
1756
1757
*/
1757
- valid = HeapTupleSatisfiesVisibility (& tp , snapshot , buffer );
1758
+ valid = HeapTupleSatisfiesVisibility (relation , & tp , snapshot , buffer );
1758
1759
CheckForSerializableConflictOut (valid , relation , & tp , buffer , snapshot );
1759
1760
if (valid )
1760
1761
* tid = ctid ;
@@ -1851,6 +1852,14 @@ ReleaseBulkInsertStatePin(BulkInsertState bistate)
1851
1852
}
1852
1853
1853
1854
1855
+ static TransactionId
1856
+ GetTransactionId (Relation relation )
1857
+ {
1858
+ TransactionId xid = relation -> rd_rel -> relpersistence == RELPERSISTENCE_SESSION
1859
+ ? GetReplicaTransactionId ()
1860
+ : GetCurrentTransactionId ();
1861
+ }
1862
+
1854
1863
/*
1855
1864
* heap_insert - insert tuple into a heap
1856
1865
*
@@ -1873,7 +1882,7 @@ void
1873
1882
heap_insert (Relation relation , HeapTuple tup , CommandId cid ,
1874
1883
int options , BulkInsertState bistate )
1875
1884
{
1876
- TransactionId xid = GetCurrentTransactionId ( );
1885
+ TransactionId xid = GetTransactionId ( relation );
1877
1886
HeapTuple heaptup ;
1878
1887
Buffer buffer ;
1879
1888
Buffer vmbuffer = InvalidBuffer ;
@@ -2110,7 +2119,7 @@ void
2110
2119
heap_multi_insert (Relation relation , TupleTableSlot * * slots , int ntuples ,
2111
2120
CommandId cid , int options , BulkInsertState bistate )
2112
2121
{
2113
- TransactionId xid = GetCurrentTransactionId ( );
2122
+ TransactionId xid = GetTransactionId ( relation );
2114
2123
HeapTuple * heaptuples ;
2115
2124
int i ;
2116
2125
int ndone ;
@@ -2449,7 +2458,7 @@ heap_delete(Relation relation, ItemPointer tid,
2449
2458
TM_FailureData * tmfd , bool changingPart )
2450
2459
{
2451
2460
TM_Result result ;
2452
- TransactionId xid = GetCurrentTransactionId ( );
2461
+ TransactionId xid = GetTransactionId ( relation );
2453
2462
ItemId lp ;
2454
2463
HeapTupleData tp ;
2455
2464
Page page ;
@@ -2514,7 +2523,7 @@ heap_delete(Relation relation, ItemPointer tid,
2514
2523
tp .t_self = * tid ;
2515
2524
2516
2525
l1 :
2517
- result = HeapTupleSatisfiesUpdate (& tp , cid , buffer );
2526
+ result = HeapTupleSatisfiesUpdate (relation , & tp , cid , buffer );
2518
2527
2519
2528
if (result == TM_Invisible )
2520
2529
{
@@ -2633,7 +2642,7 @@ heap_delete(Relation relation, ItemPointer tid,
2633
2642
if (crosscheck != InvalidSnapshot && result == TM_Ok )
2634
2643
{
2635
2644
/* Perform additional check for transaction-snapshot mode RI updates */
2636
- if (!HeapTupleSatisfiesVisibility (& tp , crosscheck , buffer ))
2645
+ if (!HeapTupleSatisfiesVisibility (relation , & tp , crosscheck , buffer ))
2637
2646
result = TM_Updated ;
2638
2647
}
2639
2648
@@ -2900,7 +2909,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
2900
2909
TM_FailureData * tmfd , LockTupleMode * lockmode )
2901
2910
{
2902
2911
TM_Result result ;
2903
- TransactionId xid = GetCurrentTransactionId ( );
2912
+ TransactionId xid = GetTransactionId ( relation );
2904
2913
Bitmapset * hot_attrs ;
2905
2914
Bitmapset * key_attrs ;
2906
2915
Bitmapset * id_attrs ;
@@ -3070,7 +3079,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
3070
3079
l2 :
3071
3080
checked_lockers = false;
3072
3081
locker_remains = false;
3073
- result = HeapTupleSatisfiesUpdate (& oldtup , cid , buffer );
3082
+ result = HeapTupleSatisfiesUpdate (relation , & oldtup , cid , buffer );
3074
3083
3075
3084
/* see below about the "no wait" case */
3076
3085
Assert (result != TM_BeingModified || wait );
@@ -3262,7 +3271,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
3262
3271
if (crosscheck != InvalidSnapshot && result == TM_Ok )
3263
3272
{
3264
3273
/* Perform additional check for transaction-snapshot mode RI updates */
3265
- if (!HeapTupleSatisfiesVisibility (& oldtup , crosscheck , buffer ))
3274
+ if (!HeapTupleSatisfiesVisibility (relation , & oldtup , crosscheck , buffer ))
3266
3275
{
3267
3276
result = TM_Updated ;
3268
3277
Assert (!ItemPointerEquals (& oldtup .t_self , & oldtup .t_data -> t_ctid ));
@@ -4018,7 +4027,7 @@ heap_lock_tuple(Relation relation, HeapTuple tuple,
4018
4027
tuple -> t_tableOid = RelationGetRelid (relation );
4019
4028
4020
4029
l3 :
4021
- result = HeapTupleSatisfiesUpdate (tuple , cid , * buffer );
4030
+ result = HeapTupleSatisfiesUpdate (relation , tuple , cid , * buffer );
4022
4031
4023
4032
if (result == TM_Invisible )
4024
4033
{
@@ -4193,7 +4202,7 @@ heap_lock_tuple(Relation relation, HeapTuple tuple,
4193
4202
TM_Result res ;
4194
4203
4195
4204
res = heap_lock_updated_tuple (relation , tuple , & t_ctid ,
4196
- GetCurrentTransactionId ( ),
4205
+ GetTransactionId ( relation ),
4197
4206
mode );
4198
4207
if (res != TM_Ok )
4199
4208
{
@@ -4441,7 +4450,7 @@ heap_lock_tuple(Relation relation, HeapTuple tuple,
4441
4450
TM_Result res ;
4442
4451
4443
4452
res = heap_lock_updated_tuple (relation , tuple , & t_ctid ,
4444
- GetCurrentTransactionId ( ),
4453
+ GetTransactionId ( relation ),
4445
4454
mode );
4446
4455
if (res != TM_Ok )
4447
4456
{
@@ -4550,7 +4559,7 @@ heap_lock_tuple(Relation relation, HeapTuple tuple,
4550
4559
* state if multixact.c elogs.
4551
4560
*/
4552
4561
compute_new_xmax_infomask (xmax , old_infomask , tuple -> t_data -> t_infomask2 ,
4553
- GetCurrentTransactionId ( ), mode , false,
4562
+ GetTransactionId ( relation ), mode , false,
4554
4563
& xid , & new_infomask , & new_infomask2 );
4555
4564
4556
4565
START_CRIT_SECTION ();
@@ -5570,7 +5579,7 @@ heap_finish_speculative(Relation relation, ItemPointer tid)
5570
5579
void
5571
5580
heap_abort_speculative (Relation relation , ItemPointer tid )
5572
5581
{
5573
- TransactionId xid = GetCurrentTransactionId ( );
5582
+ TransactionId xid = GetTransactionId ( relation );
5574
5583
ItemId lp ;
5575
5584
HeapTupleData tp ;
5576
5585
Page page ;
0 commit comments