diff options
author | Robert Haas <rhaas@postgresql.org> | 2016-02-04 21:15:57 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2016-02-04 21:15:57 -0500 |
commit | 1f3294c22f614da74dd98a2ef69137bfa9135c96 (patch) | |
tree | 42ef100990135368cc828698f93dd850b607ef87 /src/backend/executor/nodeModifyTable.c | |
parent | 411e2b0d59947b8fce39906b4722781895e31b1e (diff) | |
download | postgresql-1f3294c22f614da74dd98a2ef69137bfa9135c96.tar.gz postgresql-1f3294c22f614da74dd98a2ef69137bfa9135c96.zip |
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
Diffstat (limited to 'src/backend/executor/nodeModifyTable.c')
-rw-r--r-- | src/backend/executor/nodeModifyTable.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c index 8ac60477fb8..9fb2ea17775 100644 --- a/src/backend/executor/nodeModifyTable.c +++ b/src/backend/executor/nodeModifyTable.c @@ -242,6 +242,12 @@ ExecInsert(TupleTableSlot *slot, /* FDW might have changed tuple */ tuple = ExecMaterializeSlot(slot); + /* + * AFTER ROW Triggers or RETURNING expressions might reference the + * tableoid column, so initialize t_tableOid before evaluating them. + */ + tuple->t_tableOid = RelationGetRelid(resultRelationDesc); + newId = InvalidOid; } else @@ -364,6 +370,8 @@ ExecDelete(ItemPointer tupleid, } else if (resultRelInfo->ri_FdwRoutine) { + HeapTuple tuple; + /* * delete from foreign table: let the FDW do it * @@ -382,6 +390,15 @@ ExecDelete(ItemPointer tupleid, if (slot == NULL) /* "do nothing" */ return NULL; + + /* + * RETURNING expressions might reference the tableoid column, so + * initialize t_tableOid before evaluating them. + */ + if (slot->tts_isempty) + ExecStoreAllNullTuple(slot); + tuple = ExecMaterializeSlot(slot); + tuple->t_tableOid = RelationGetRelid(resultRelationDesc); } else { @@ -641,6 +658,12 @@ ExecUpdate(ItemPointer tupleid, /* FDW might have changed tuple */ tuple = ExecMaterializeSlot(slot); + + /* + * AFTER ROW Triggers or RETURNING expressions might reference the + * tableoid column, so initialize t_tableOid before evaluating them. + */ + tuple->t_tableOid = RelationGetRelid(resultRelationDesc); } else { |