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

Commite434d36

Browse files
committed
Fix assertions with RI triggers in heap_update and heap_delete.
If the tuple being updated is not visible to the crosscheck snapshot,we return TM_Updated but the assertions would not hold in that case.Move them to before the cross-check.Fixes bug #17893. Backpatch to all supported versions.Author: Alexander LakhinBackpatch-through: 12Discussion:https://www.postgresql.org/message-id/17893-35847009eec517b5%40postgresql.org
1 parent2c4dd36 commite434d36

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

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

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,13 +2646,7 @@ heap_delete(Relation relation, ItemPointer tid,
26462646
result=TM_Deleted;
26472647
}
26482648

2649-
if (crosscheck!=InvalidSnapshot&&result==TM_Ok)
2650-
{
2651-
/* Perform additional check for transaction-snapshot mode RI updates */
2652-
if (!HeapTupleSatisfiesVisibility(&tp,crosscheck,buffer))
2653-
result=TM_Updated;
2654-
}
2655-
2649+
/* sanity check the result HeapTupleSatisfiesUpdate() and the logic above */
26562650
if (result!=TM_Ok)
26572651
{
26582652
Assert(result==TM_SelfModified||
@@ -2662,6 +2656,17 @@ heap_delete(Relation relation, ItemPointer tid,
26622656
Assert(!(tp.t_data->t_infomask&HEAP_XMAX_INVALID));
26632657
Assert(result!=TM_Updated||
26642658
!ItemPointerEquals(&tp.t_self,&tp.t_data->t_ctid));
2659+
}
2660+
2661+
if (crosscheck!=InvalidSnapshot&&result==TM_Ok)
2662+
{
2663+
/* Perform additional check for transaction-snapshot mode RI updates */
2664+
if (!HeapTupleSatisfiesVisibility(&tp,crosscheck,buffer))
2665+
result=TM_Updated;
2666+
}
2667+
2668+
if (result!=TM_Ok)
2669+
{
26652670
tmfd->ctid=tp.t_data->t_ctid;
26662671
tmfd->xmax=HeapTupleHeaderGetUpdateXid(tp.t_data);
26672672
if (result==TM_SelfModified)
@@ -3289,16 +3294,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
32893294
result=TM_Deleted;
32903295
}
32913296

3292-
if (crosscheck!=InvalidSnapshot&&result==TM_Ok)
3293-
{
3294-
/* Perform additional check for transaction-snapshot mode RI updates */
3295-
if (!HeapTupleSatisfiesVisibility(&oldtup,crosscheck,buffer))
3296-
{
3297-
result=TM_Updated;
3298-
Assert(!ItemPointerEquals(&oldtup.t_self,&oldtup.t_data->t_ctid));
3299-
}
3300-
}
3301-
3297+
/* Sanity check the result HeapTupleSatisfiesUpdate() and the logic above */
33023298
if (result!=TM_Ok)
33033299
{
33043300
Assert(result==TM_SelfModified||
@@ -3308,6 +3304,17 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
33083304
Assert(!(oldtup.t_data->t_infomask&HEAP_XMAX_INVALID));
33093305
Assert(result!=TM_Updated||
33103306
!ItemPointerEquals(&oldtup.t_self,&oldtup.t_data->t_ctid));
3307+
}
3308+
3309+
if (crosscheck!=InvalidSnapshot&&result==TM_Ok)
3310+
{
3311+
/* Perform additional check for transaction-snapshot mode RI updates */
3312+
if (!HeapTupleSatisfiesVisibility(&oldtup,crosscheck,buffer))
3313+
result=TM_Updated;
3314+
}
3315+
3316+
if (result!=TM_Ok)
3317+
{
33113318
tmfd->ctid=oldtup.t_data->t_ctid;
33123319
tmfd->xmax=HeapTupleHeaderGetUpdateXid(oldtup.t_data);
33133320
if (result==TM_SelfModified)

‎src/include/access/tableam.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,8 +1235,8 @@ table_multi_insert(Relation rel, TupleTableSlot **slots, int nslots,
12351235
* TM_BeingModified (the last only possible if wait == false).
12361236
*
12371237
* In the failure cases, the routine fills *tmfd with the tuple's t_ctid,
1238-
* t_xmax, and, if possible,and, if possible,t_cmax. See comments for
1239-
*structTM_FailureData for additional info.
1238+
* t_xmax, and, if possible, t_cmax. See comments for struct
1239+
* TM_FailureData for additional info.
12401240
*/
12411241
staticinlineTM_Result
12421242
table_tuple_delete(Relationrel,ItemPointertid,CommandIdcid,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp