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

Commit1f3294c

Browse files
committed
When modifying a foreign table, initialize tableoid field properly.
Failure to do this can cause AFTER ROW triggers or RETURNING expressionsthat reference this field to misbehave.Etsuro Fujita, reviewed by Thom Brown
1 parent411e2b0 commit1f3294c

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
elseif (resultRelInfo->ri_FdwRoutine)
366372
{
373+
HeapTupletuple;
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
returnNULL;
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)

[8]ページ先頭

©2009-2025 Movatter.jp