@@ -242,6 +242,12 @@ ExecInsert(TupleTableSlot *slot,
242
242
/* FDW might have changed tuple */
243
243
tuple = ExecMaterializeSlot (slot );
244
244
245
+ /*
246
+ * AFTER ROW Triggers or RETURNING expressions might reference the
247
+ * tableoid column, so initialize t_tableOid before evaluating them.
248
+ */
249
+ tuple -> t_tableOid = RelationGetRelid (resultRelationDesc );
250
+
245
251
newId = InvalidOid ;
246
252
}
247
253
else
@@ -364,6 +370,8 @@ ExecDelete(ItemPointer tupleid,
364
370
}
365
371
else if (resultRelInfo -> ri_FdwRoutine )
366
372
{
373
+ HeapTuple tuple ;
374
+
367
375
/*
368
376
* delete from foreign table: let the FDW do it
369
377
*
@@ -382,6 +390,15 @@ ExecDelete(ItemPointer tupleid,
382
390
383
391
if (slot == NULL ) /* "do nothing" */
384
392
return NULL ;
393
+
394
+ /*
395
+ * RETURNING expressions might reference the tableoid column, so
396
+ * initialize t_tableOid before evaluating them.
397
+ */
398
+ if (slot -> tts_isempty )
399
+ ExecStoreAllNullTuple (slot );
400
+ tuple = ExecMaterializeSlot (slot );
401
+ tuple -> t_tableOid = RelationGetRelid (resultRelationDesc );
385
402
}
386
403
else
387
404
{
@@ -641,6 +658,12 @@ ExecUpdate(ItemPointer tupleid,
641
658
642
659
/* FDW might have changed tuple */
643
660
tuple = ExecMaterializeSlot (slot );
661
+
662
+ /*
663
+ * AFTER ROW Triggers or RETURNING expressions might reference the
664
+ * tableoid column, so initialize t_tableOid before evaluating them.
665
+ */
666
+ tuple -> t_tableOid = RelationGetRelid (resultRelationDesc );
644
667
}
645
668
else
646
669
{
0 commit comments