1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-19 13:42:17 +03:00

Add TupleTableSlotOps.is_current_xact_tuple() method

This allows us to abstract how/whether table AM uses transaction identifiers.
A custom table AM can use a custom slot, which may not store xmin directly,
but determine the tuple belonging to the current transaction in the other way.

Discussion: https://postgr.es/m/CAPpHfdurb9ycV8udYqM%3Do0sPS66PJ4RCBM1g-bBpvzUfogY0EA%40mail.gmail.com
Reviewed-by: Matthias van de Meent, Mark Dilger, Pavel Borisov
Reviewed-by: Nikita Malakhov, Japin Li
This commit is contained in:
Alexander Korotkov
2024-03-21 23:00:43 +02:00
parent c35a3fb5e0
commit 0997e0af27
3 changed files with 101 additions and 7 deletions

View File

@@ -1260,9 +1260,6 @@ RI_FKey_fk_upd_check_required(Trigger *trigger, Relation fk_rel,
{
const RI_ConstraintInfo *riinfo;
int ri_nullcheck;
Datum xminDatum;
TransactionId xmin;
bool isnull;
/*
* AfterTriggerSaveEvent() handles things such that this function is never
@@ -1330,10 +1327,7 @@ RI_FKey_fk_upd_check_required(Trigger *trigger, Relation fk_rel,
* this if we knew the INSERT trigger already fired, but there is no easy
* way to know that.)
*/
xminDatum = slot_getsysattr(oldslot, MinTransactionIdAttributeNumber, &isnull);
Assert(!isnull);
xmin = DatumGetTransactionId(xminDatum);
if (TransactionIdIsCurrentTransactionId(xmin))
if (slot_is_current_xact_tuple(oldslot))
return true;
/* If all old and new key values are equal, no check is needed */