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

Commit 85adb5e

Browse files
committed
Remove pointless HeapTupleHeaderIndicatesMovedPartitions calls
Pavan Deolasee recently noted that a few of the HeapTupleHeaderIndicatesMovedPartitions calls added by commit 5db6df0 are useless, since they are done after comparing t_self with t_ctid. But because t_self can never be set to the magical values that indicate that the tuple moved partition, this can never succeed: if the first test fails (so we know t_self equals t_ctid), necessarily the second test will also fail. So these checks can be removed and no harm is done. Discussion: https://postgr.es/m/20200929164411.GA15497@alvherre.pgsql
1 parent 2203ede commit 85adb5e

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

src/backend/access/heap/heapam.c

+4-8
Original file line numberDiff line numberDiff line change
@@ -2618,8 +2618,7 @@ heap_delete(Relation relation, ItemPointer tid,
26182618
HEAP_XMAX_IS_LOCKED_ONLY(tp.t_data->t_infomask) ||
26192619
HeapTupleHeaderIsOnlyLocked(tp.t_data))
26202620
result = TM_Ok;
2621-
else if (!ItemPointerEquals(&tp.t_self, &tp.t_data->t_ctid) ||
2622-
HeapTupleHeaderIndicatesMovedPartitions(tp.t_data))
2621+
else if (!ItemPointerEquals(&tp.t_self, &tp.t_data->t_ctid))
26232622
result = TM_Updated;
26242623
else
26252624
result = TM_Deleted;
@@ -3248,8 +3247,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
32483247

32493248
if (can_continue)
32503249
result = TM_Ok;
3251-
else if (!ItemPointerEquals(&oldtup.t_self, &oldtup.t_data->t_ctid) ||
3252-
HeapTupleHeaderIndicatesMovedPartitions(oldtup.t_data))
3250+
else if (!ItemPointerEquals(&oldtup.t_self, &oldtup.t_data->t_ctid))
32533251
result = TM_Updated;
32543252
else
32553253
result = TM_Deleted;
@@ -4485,8 +4483,7 @@ heap_lock_tuple(Relation relation, HeapTuple tuple,
44854483
HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_data->t_infomask) ||
44864484
HeapTupleHeaderIsOnlyLocked(tuple->t_data))
44874485
result = TM_Ok;
4488-
else if (!ItemPointerEquals(&tuple->t_self, &tuple->t_data->t_ctid) ||
4489-
HeapTupleHeaderIndicatesMovedPartitions(tuple->t_data))
4486+
else if (!ItemPointerEquals(&tuple->t_self, &tuple->t_data->t_ctid))
44904487
result = TM_Updated;
44914488
else
44924489
result = TM_Deleted;
@@ -5059,8 +5056,7 @@ test_lockmode_for_conflict(MultiXactStatus status, TransactionId xid,
50595056
LOCKMODE_from_mxstatus(wantedstatus)))
50605057
{
50615058
/* bummer */
5062-
if (!ItemPointerEquals(&tup->t_self, &tup->t_data->t_ctid) ||
5063-
HeapTupleHeaderIndicatesMovedPartitions(tup->t_data))
5059+
if (!ItemPointerEquals(&tup->t_self, &tup->t_data->t_ctid))
50645060
return TM_Updated;
50655061
else
50665062
return TM_Deleted;

src/backend/access/heap/heapam_visibility.c

+3-6
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
607607
{
608608
if (HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask))
609609
return TM_Ok;
610-
if (!ItemPointerEquals(&htup->t_self, &tuple->t_ctid) ||
611-
HeapTupleHeaderIndicatesMovedPartitions(tuple))
610+
if (!ItemPointerEquals(&htup->t_self, &tuple->t_ctid))
612611
return TM_Updated; /* updated by other */
613612
else
614613
return TM_Deleted; /* deleted by other */
@@ -653,8 +652,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
653652

654653
if (TransactionIdDidCommit(xmax))
655654
{
656-
if (!ItemPointerEquals(&htup->t_self, &tuple->t_ctid) ||
657-
HeapTupleHeaderIndicatesMovedPartitions(tuple))
655+
if (!ItemPointerEquals(&htup->t_self, &tuple->t_ctid))
658656
return TM_Updated;
659657
else
660658
return TM_Deleted;
@@ -714,8 +712,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
714712

715713
SetHintBits(tuple, buffer, HEAP_XMAX_COMMITTED,
716714
HeapTupleHeaderGetRawXmax(tuple));
717-
if (!ItemPointerEquals(&htup->t_self, &tuple->t_ctid) ||
718-
HeapTupleHeaderIndicatesMovedPartitions(tuple))
715+
if (!ItemPointerEquals(&htup->t_self, &tuple->t_ctid))
719716
return TM_Updated; /* updated by other */
720717
else
721718
return TM_Deleted; /* deleted by other */

0 commit comments

Comments
 (0)