Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0f5505a

Browse files
committed
Remove pointless HeapTupleHeaderIndicatesMovedPartitions calls
Pavan Deolasee recently noted that a few of theHeapTupleHeaderIndicatesMovedPartitions calls added by commit5db6df0 are useless, since they are done after comparing t_selfwith t_ctid. But because t_self can never be set to the magical valuesthat indicate that the tuple moved partition, this can never succeed: ifthe first test fails (so we know t_self equals t_ctid), necessarily thesecond test will also fail.So these checks can be removed and no harm is done. There's no bughere, just a code legibility issue.Reported-by: Pavan Deolasee <pavan.deolasee@gmail.com>Discussion:https://postgr.es/m/20200929164411.GA15497@alvherre.pgsql
1 parent6a03369 commit0f5505a

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

‎src/backend/access/heap/heapam.c

Lines changed: 4 additions & 8 deletions
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-
elseif (!ItemPointerEquals(&tp.t_self,&tp.t_data->t_ctid)||
2773-
HeapTupleHeaderIndicatesMovedPartitions(tp.t_data))
2772+
elseif (!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-
elseif (!ItemPointerEquals(&oldtup.t_self,&oldtup.t_data->t_ctid)||
3403-
HeapTupleHeaderIndicatesMovedPartitions(oldtup.t_data))
3401+
elseif (!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-
elseif (!ItemPointerEquals(&tuple->t_self,&tuple->t_data->t_ctid)||
4640-
HeapTupleHeaderIndicatesMovedPartitions(tuple->t_data))
4637+
elseif (!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
returnTM_Updated;
52165212
else
52175213
returnTM_Deleted;

‎src/backend/access/heap/heapam_visibility.c

Lines changed: 3 additions & 6 deletions
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
returnTM_Ok;
610-
if (!ItemPointerEquals(&htup->t_self,&tuple->t_ctid)||
611-
HeapTupleHeaderIndicatesMovedPartitions(tuple))
610+
if (!ItemPointerEquals(&htup->t_self,&tuple->t_ctid))
612611
returnTM_Updated;/* updated by other */
613612
else
614613
returnTM_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
returnTM_Updated;
659657
else
660658
returnTM_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
returnTM_Updated;/* updated by other */
720717
else
721718
returnTM_Deleted;/* deleted by other */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp