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

Commit9418d79

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 parentf8003e0 commit9418d79

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
@@ -308,6 +308,12 @@ ExecInsert(ModifyTableState *mtstate,
308308
/* FDW might have changed tuple */
309309
tuple=ExecMaterializeSlot(slot);
310310

311+
/*
312+
* AFTER ROW Triggers or RETURNING expressions might reference the
313+
* tableoid column, so initialize t_tableOid before evaluating them.
314+
*/
315+
tuple->t_tableOid=RelationGetRelid(resultRelationDesc);
316+
311317
newId=InvalidOid;
312318
}
313319
else
@@ -561,6 +567,8 @@ ExecDelete(ItemPointer tupleid,
561567
}
562568
elseif (resultRelInfo->ri_FdwRoutine)
563569
{
570+
HeapTupletuple;
571+
564572
/*
565573
* delete from foreign table: let the FDW do it
566574
*
@@ -579,6 +587,15 @@ ExecDelete(ItemPointer tupleid,
579587

580588
if (slot==NULL)/* "do nothing" */
581589
returnNULL;
590+
591+
/*
592+
* RETURNING expressions might reference the tableoid column, so
593+
* initialize t_tableOid before evaluating them.
594+
*/
595+
if (slot->tts_isempty)
596+
ExecStoreAllNullTuple(slot);
597+
tuple=ExecMaterializeSlot(slot);
598+
tuple->t_tableOid=RelationGetRelid(resultRelationDesc);
582599
}
583600
else
584601
{
@@ -838,6 +855,12 @@ ExecUpdate(ItemPointer tupleid,
838855

839856
/* FDW might have changed tuple */
840857
tuple=ExecMaterializeSlot(slot);
858+
859+
/*
860+
* AFTER ROW Triggers or RETURNING expressions might reference the
861+
* tableoid column, so initialize t_tableOid before evaluating them.
862+
*/
863+
tuple->t_tableOid=RelationGetRelid(resultRelationDesc);
841864
}
842865
else
843866
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp