mirror of
https://github.com/postgres/postgres.git
synced 2025-06-27 23:21:58 +03:00
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 Lakhin Backpatch-through: 12 Discussion: https://www.postgresql.org/message-id/17893-35847009eec517b5%40postgresql.org
This commit is contained in:
@ -2856,13 +2856,7 @@ l1:
|
||||
result = TM_Deleted;
|
||||
}
|
||||
|
||||
if (crosscheck != InvalidSnapshot && result == TM_Ok)
|
||||
{
|
||||
/* Perform additional check for transaction-snapshot mode RI updates */
|
||||
if (!HeapTupleSatisfiesVisibility(&tp, crosscheck, buffer))
|
||||
result = TM_Updated;
|
||||
}
|
||||
|
||||
/* sanity check the result HeapTupleSatisfiesUpdate() and the logic above */
|
||||
if (result != TM_Ok)
|
||||
{
|
||||
Assert(result == TM_SelfModified ||
|
||||
@ -2872,6 +2866,17 @@ l1:
|
||||
Assert(!(tp.t_data->t_infomask & HEAP_XMAX_INVALID));
|
||||
Assert(result != TM_Updated ||
|
||||
!ItemPointerEquals(&tp.t_self, &tp.t_data->t_ctid));
|
||||
}
|
||||
|
||||
if (crosscheck != InvalidSnapshot && result == TM_Ok)
|
||||
{
|
||||
/* Perform additional check for transaction-snapshot mode RI updates */
|
||||
if (!HeapTupleSatisfiesVisibility(&tp, crosscheck, buffer))
|
||||
result = TM_Updated;
|
||||
}
|
||||
|
||||
if (result != TM_Ok)
|
||||
{
|
||||
tmfd->ctid = tp.t_data->t_ctid;
|
||||
tmfd->xmax = HeapTupleHeaderGetUpdateXid(tp.t_data);
|
||||
if (result == TM_SelfModified)
|
||||
@ -3483,16 +3488,7 @@ l2:
|
||||
result = TM_Deleted;
|
||||
}
|
||||
|
||||
if (crosscheck != InvalidSnapshot && result == TM_Ok)
|
||||
{
|
||||
/* Perform additional check for transaction-snapshot mode RI updates */
|
||||
if (!HeapTupleSatisfiesVisibility(&oldtup, crosscheck, buffer))
|
||||
{
|
||||
result = TM_Updated;
|
||||
Assert(!ItemPointerEquals(&oldtup.t_self, &oldtup.t_data->t_ctid));
|
||||
}
|
||||
}
|
||||
|
||||
/* Sanity check the result HeapTupleSatisfiesUpdate() and the logic above */
|
||||
if (result != TM_Ok)
|
||||
{
|
||||
Assert(result == TM_SelfModified ||
|
||||
@ -3502,6 +3498,17 @@ l2:
|
||||
Assert(!(oldtup.t_data->t_infomask & HEAP_XMAX_INVALID));
|
||||
Assert(result != TM_Updated ||
|
||||
!ItemPointerEquals(&oldtup.t_self, &oldtup.t_data->t_ctid));
|
||||
}
|
||||
|
||||
if (crosscheck != InvalidSnapshot && result == TM_Ok)
|
||||
{
|
||||
/* Perform additional check for transaction-snapshot mode RI updates */
|
||||
if (!HeapTupleSatisfiesVisibility(&oldtup, crosscheck, buffer))
|
||||
result = TM_Updated;
|
||||
}
|
||||
|
||||
if (result != TM_Ok)
|
||||
{
|
||||
tmfd->ctid = oldtup.t_data->t_ctid;
|
||||
tmfd->xmax = HeapTupleHeaderGetUpdateXid(oldtup.t_data);
|
||||
if (result == TM_SelfModified)
|
||||
|
Reference in New Issue
Block a user