Content-Length: 330089 | pFad | http://github.com/postgrespro/postgres/commit/1f3294c22f614da74dd98a2ef69137bfa9135c96

05 When modifying a foreign table, initialize tableoid field properly. · postgrespro/postgres@1f3294c · GitHub
Skip to content

Commit 1f3294c

Browse files
committed
When modifying a foreign table, initialize tableoid field properly.
Failure to do this can cause AFTER ROW triggers or RETURNING expressions that reference this field to misbehave. Etsuro Fujita, reviewed by Thom Brown
1 parent 411e2b0 commit 1f3294c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/backend/executor/nodeModifyTable.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,12 @@ ExecInsert(TupleTableSlot *slot,
242242
/* FDW might have changed tuple */
243243
tuple = ExecMaterializeSlot(slot);
244244

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+
245251
newId = InvalidOid;
246252
}
247253
else
@@ -364,6 +370,8 @@ ExecDelete(ItemPointer tupleid,
364370
}
365371
else if (resultRelInfo->ri_FdwRoutine)
366372
{
373+
HeapTuple tuple;
374+
367375
/*
368376
* delete from foreign table: let the FDW do it
369377
*
@@ -382,6 +390,15 @@ ExecDelete(ItemPointer tupleid,
382390

383391
if (slot == NULL) /* "do nothing" */
384392
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);
385402
}
386403
else
387404
{
@@ -641,6 +658,12 @@ ExecUpdate(ItemPointer tupleid,
641658

642659
/* FDW might have changed tuple */
643660
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);
644667
}
645668
else
646669
{

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/1f3294c22f614da74dd98a2ef69137bfa9135c96

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy