aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/copy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/copy.c')
-rw-r--r--src/backend/commands/copy.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index a4c02e6b7c5..f391828e74f 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -1416,6 +1416,12 @@ BeginCopy(ParseState *pstate,
errmsg("table \"%s\" does not have OIDs",
RelationGetRelationName(cstate->rel))));
+ /*
+ * If there are any triggers with transition tables on the named
+ * relation, we need to be prepared to capture transition tuples.
+ */
+ cstate->transition_capture = MakeTransitionCaptureState(rel->trigdesc);
+
/* Initialize state for CopyFrom tuple routing. */
if (is_from && rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
{
@@ -1440,14 +1446,6 @@ BeginCopy(ParseState *pstate,
cstate->partition_tuple_slot = partition_tuple_slot;
/*
- * If there are any triggers with transition tables on the named
- * relation, we need to be prepared to capture transition tuples
- * from child relations too.
- */
- cstate->transition_capture =
- MakeTransitionCaptureState(rel->trigdesc);
-
- /*
* If we are capturing transition tuples, they may need to be
* converted from partition format back to partitioned table
* format (this is only ever necessary if a BEFORE trigger
@@ -2807,7 +2805,7 @@ CopyFrom(CopyState cstate)
pq_endmsgread();
/* Execute AFTER STATEMENT insertion triggers */
- ExecASInsertTriggers(estate, resultRelInfo);
+ ExecASInsertTriggers(estate, resultRelInfo, cstate->transition_capture);
/* Handle queued AFTER triggers */
AfterTriggerEndQuery(estate);
@@ -2935,7 +2933,7 @@ CopyFromInsertBatch(CopyState cstate, EState *estate, CommandId mycid,
cstate->cur_lineno = firstBufferedLineNo + i;
ExecARInsertTriggers(estate, resultRelInfo,
bufferedTuples[i],
- NIL, NULL);
+ NIL, cstate->transition_capture);
}
}