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

Commit 0f5505a

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. There's no bug here, just a code legibility issue. Reported-by: Pavan Deolasee <pavan.deolasee@gmail.com> Discussion: https://postgr.es/m/20200929164411.GA15497@alvherre.pgsql
1 parent 6a03369 commit 0f5505a

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
@@ -2769,8 +2769,7 @@ heap_delete(Relation relation, ItemPointer tid,
27692769
HEAP_XMAX_IS_LOCKED_ONLY(tp.t_data->t_infomask) ||
27702770
HeapTupleHeaderIsOnlyLocked(tp.t_data))
27712771
result = TM_Ok;
2772-
else if (!ItemPointerEquals(&tp.t_self, &tp.t_data->t_ctid) ||
2773-
HeapTupleHeaderIndicatesMovedPartitions(tp.t_data))
2772+
else if (!ItemPointerEquals(&tp.t_self, &tp.t_data->t_ctid))
27742773
result = TM_Updated;
27752774
else
27762775
result = TM_Deleted;
@@ -3399,8 +3398,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
33993398

34003399
if (can_continue)
34013400
result = TM_Ok;
3402-
else if (!ItemPointerEquals(&oldtup.t_self, &oldtup.t_data->t_ctid) ||
3403-
HeapTupleHeaderIndicatesMovedPartitions(oldtup.t_data))
3401+
else if (!ItemPointerEquals(&oldtup.t_self, &oldtup.t_data->t_ctid))
34043402
result = TM_Updated;
34053403
else
34063404
result = TM_Deleted;
@@ -4636,8 +4634,7 @@ heap_lock_tuple(Relation relation, HeapTuple tuple,
46364634
HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_data->t_infomask) ||
46374635
HeapTupleHeaderIsOnlyLocked(tuple->t_data))
46384636
result = TM_Ok;
4639-
else if (!ItemPointerEquals(&tuple->t_self, &tuple->t_data->t_ctid) ||
4640-
HeapTupleHeaderIndicatesMovedPartitions(tuple->t_data))
4637+
else if (!ItemPointerEquals(&tuple->t_self, &tuple->t_data->t_ctid))
46414638
result = TM_Updated;
46424639
else
46434640
result = TM_Deleted;
@@ -5210,8 +5207,7 @@ test_lockmode_for_conflict(MultiXactStatus status, TransactionId xid,
52105207
LOCKMODE_from_mxstatus(wantedstatus)))
52115208
{
52125209
/* bummer */
5213-
if (!ItemPointerEquals(&tup->t_self, &tup->t_data->t_ctid) ||
5214-
HeapTupleHeaderIndicatesMovedPartitions(tup->t_data))
5210+
if (!ItemPointerEquals(&tup->t_self, &tup->t_data->t_ctid))
52155211
return TM_Updated;
52165212
else
52175213
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)