aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/copy.c18
-rw-r--r--src/backend/commands/tablecmds.c3
2 files changed, 14 insertions, 7 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index dbb06397e6b..93aa1631775 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -2710,10 +2710,10 @@ CopyFrom(CopyState cstate)
tuple = heap_form_tuple(tupDesc, values, nulls);
/*
- * Constraints might reference the tableoid column, so initialize
- * t_tableOid before evaluating them.
+ * Constraints might reference the tableoid column, so (re-)initialize
+ * tts_tableOid before evaluating them.
*/
- tuple->t_tableOid = RelationGetRelid(target_resultRelInfo->ri_RelationDesc);
+ myslot->tts_tableOid = RelationGetRelid(target_resultRelInfo->ri_RelationDesc);
/* Triggers and stuff need to be invoked in query context. */
MemoryContextSwitchTo(oldcontext);
@@ -2899,7 +2899,7 @@ CopyFrom(CopyState cstate)
MemoryContextSwitchTo(oldcontext);
}
- tuple->t_tableOid = RelationGetRelid(resultRelInfo->ri_RelationDesc);
+ slot->tts_tableOid = RelationGetRelid(resultRelInfo->ri_RelationDesc);
}
skip_tuple = false;
@@ -2995,14 +2995,18 @@ CopyFrom(CopyState cstate)
/*
* AFTER ROW Triggers might reference the tableoid
- * column, so initialize t_tableOid before evaluating
- * them.
+ * column, so (re-)initialize tts_tableOid before
+ * evaluating them.
*/
- tuple->t_tableOid = RelationGetRelid(resultRelInfo->ri_RelationDesc);
+ slot->tts_tableOid = RelationGetRelid(resultRelInfo->ri_RelationDesc);
}
else
+ {
heap_insert(resultRelInfo->ri_RelationDesc, tuple,
mycid, hi_options, bistate);
+ ItemPointerCopy(&tuple->t_self, &slot->tts_tid);
+ slot->tts_tableOid = RelationGetRelid(resultRelInfo->ri_RelationDesc);
+ }
/* And create index entries for it */
if (resultRelInfo->ri_NumIndices > 0)
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 35bdb0e0c6f..0fb0b186bb4 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -4860,7 +4860,10 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
/* Write the tuple out to the new relation */
if (newrel)
+ {
heap_insert(newrel, tuple, mycid, hi_options, bistate);
+ ItemPointerCopy(&tuple->t_self, &newslot->tts_tid);
+ }
ResetExprContext(econtext);