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

Commit59c62a2

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 parent3a95d2c commit59c62a2

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
@@ -2918,13 +2918,7 @@ heap_delete(Relation relation, ItemPointer tid,
29182918
result=TM_Deleted;
29192919
}
29202920

2921-
if (crosscheck!=InvalidSnapshot&&result==TM_Ok)
2922-
{
2923-
/* Perform additional check for transaction-snapshot mode RI updates */
2924-
if (!HeapTupleSatisfiesVisibility(&tp,crosscheck,buffer))
2925-
result=TM_Updated;
2926-
}
2927-
2921+
/* sanity check the result HeapTupleSatisfiesUpdate() and the logic above */
29282922
if (result!=TM_Ok)
29292923
{
29302924
Assert(result==TM_SelfModified||
@@ -2934,6 +2928,17 @@ heap_delete(Relation relation, ItemPointer tid,
29342928
Assert(!(tp.t_data->t_infomask&HEAP_XMAX_INVALID));
29352929
Assert(result!=TM_Updated||
29362930
!ItemPointerEquals(&tp.t_self,&tp.t_data->t_ctid));
2931+
}
2932+
2933+
if (crosscheck!=InvalidSnapshot&&result==TM_Ok)
2934+
{
2935+
/* Perform additional check for transaction-snapshot mode RI updates */
2936+
if (!HeapTupleSatisfiesVisibility(&tp,crosscheck,buffer))
2937+
result=TM_Updated;
2938+
}
2939+
2940+
if (result!=TM_Ok)
2941+
{
29372942
tmfd->ctid=tp.t_data->t_ctid;
29382943
tmfd->xmax=HeapTupleHeaderGetUpdateXid(tp.t_data);
29392944
if (result==TM_SelfModified)
@@ -3563,16 +3568,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
35633568
result=TM_Deleted;
35643569
}
35653570

3566-
if (crosscheck!=InvalidSnapshot&&result==TM_Ok)
3567-
{
3568-
/* Perform additional check for transaction-snapshot mode RI updates */
3569-
if (!HeapTupleSatisfiesVisibility(&oldtup,crosscheck,buffer))
3570-
{
3571-
result=TM_Updated;
3572-
Assert(!ItemPointerEquals(&oldtup.t_self,&oldtup.t_data->t_ctid));
3573-
}
3574-
}
3575-
3571+
/* Sanity check the result HeapTupleSatisfiesUpdate() and the logic above */
35763572
if (result!=TM_Ok)
35773573
{
35783574
Assert(result==TM_SelfModified||
@@ -3582,6 +3578,17 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
35823578
Assert(!(oldtup.t_data->t_infomask&HEAP_XMAX_INVALID));
35833579
Assert(result!=TM_Updated||
35843580
!ItemPointerEquals(&oldtup.t_self,&oldtup.t_data->t_ctid));
3581+
}
3582+
3583+
if (crosscheck!=InvalidSnapshot&&result==TM_Ok)
3584+
{
3585+
/* Perform additional check for transaction-snapshot mode RI updates */
3586+
if (!HeapTupleSatisfiesVisibility(&oldtup,crosscheck,buffer))
3587+
result=TM_Updated;
3588+
}
3589+
3590+
if (result!=TM_Ok)
3591+
{
35853592
tmfd->ctid=oldtup.t_data->t_ctid;
35863593
tmfd->xmax=HeapTupleHeaderGetUpdateXid(oldtup.t_data);
35873594
if (result==TM_SelfModified)

‎src/include/access/tableam.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,8 +1453,8 @@ table_multi_insert(Relation rel, TupleTableSlot **slots, int nslots,
14531453
* TM_BeingModified (the last only possible if wait == false).
14541454
*
14551455
* In the failure cases, the routine fills *tmfd with the tuple's t_ctid,
1456-
* t_xmax, and, if possible,and, if possible,t_cmax. See comments for
1457-
*structTM_FailureData for additional info.
1456+
* t_xmax, and, if possible, t_cmax. See comments for struct
1457+
* TM_FailureData for additional info.
14581458
*/
14591459
staticinlineTM_Result
14601460
table_tuple_delete(Relationrel,ItemPointertid,CommandIdcid,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp