aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/execMain.c1
-rw-r--r--src/backend/executor/execPartition.c7
-rw-r--r--src/backend/executor/execUtils.c4
-rw-r--r--src/backend/executor/nodeModifyTable.c31
4 files changed, 19 insertions, 24 deletions
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index 872b879387b..2c2b3a88746 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -1257,7 +1257,6 @@ InitResultRelInfo(ResultRelInfo *resultRelInfo,
resultRelInfo->ri_ChildToRootMap = NULL;
resultRelInfo->ri_ChildToRootMapValid = false;
resultRelInfo->ri_CopyMultiInsertBuffer = NULL;
- resultRelInfo->ri_ModifyTableState = NULL;
}
/*
diff --git a/src/backend/executor/execPartition.c b/src/backend/executor/execPartition.c
index 88d0ea3adb1..76d79b9741f 100644
--- a/src/backend/executor/execPartition.c
+++ b/src/backend/executor/execPartition.c
@@ -1029,13 +1029,6 @@ ExecInitRoutingInfo(ModifyTableState *mtstate,
Assert(partRelInfo->ri_BatchSize >= 1);
- /*
- * If doing batch insert, setup back-link so we can easily find the
- * mtstate again.
- */
- if (partRelInfo->ri_BatchSize > 1)
- partRelInfo->ri_ModifyTableState = mtstate;
-
partRelInfo->ri_CopyMultiInsertBuffer = NULL;
/*
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
index e296f44ebd9..87f4d53ca76 100644
--- a/src/backend/executor/execUtils.c
+++ b/src/backend/executor/execUtils.c
@@ -130,9 +130,11 @@ CreateExecutorState(void)
estate->es_result_relations = NULL;
estate->es_opened_result_relations = NIL;
estate->es_tuple_routing_result_relations = NIL;
- estate->es_insert_pending_result_relations = NIL;
estate->es_trig_target_relations = NIL;
+ estate->es_insert_pending_result_relations = NIL;
+ estate->es_insert_pending_modifytables = NIL;
+
estate->es_param_list_info = NULL;
estate->es_param_exec_vals = NULL;
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index a3988b11754..596b9a1efad 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -858,10 +858,12 @@ ExecInsert(ModifyTableContext *context,
/*
* If these are the first tuples stored in the buffers, add the
- * target rel to the es_insert_pending_result_relations list,
- * except in the case where flushing was done above, in which case
- * the target rel would already have been added to the list, so no
- * need to do this.
+ * target rel and the mtstate to the
+ * es_insert_pending_result_relations and
+ * es_insert_pending_modifytables lists respectively, execpt in
+ * the case where flushing was done above, in which case they
+ * would already have been added to the lists, so no need to do
+ * this.
*/
if (resultRelInfo->ri_NumSlots == 0 && !flushed)
{
@@ -870,6 +872,8 @@ ExecInsert(ModifyTableContext *context,
estate->es_insert_pending_result_relations =
lappend(estate->es_insert_pending_result_relations,
resultRelInfo);
+ estate->es_insert_pending_modifytables =
+ lappend(estate->es_insert_pending_modifytables, mtstate);
}
Assert(list_member_ptr(estate->es_insert_pending_result_relations,
resultRelInfo));
@@ -1219,12 +1223,14 @@ ExecBatchInsert(ModifyTableState *mtstate,
static void
ExecPendingInserts(EState *estate)
{
- ListCell *lc;
+ ListCell *l1,
+ *l2;
- foreach(lc, estate->es_insert_pending_result_relations)
+ forboth(l1, estate->es_insert_pending_result_relations,
+ l2, estate->es_insert_pending_modifytables)
{
- ResultRelInfo *resultRelInfo = (ResultRelInfo *) lfirst(lc);
- ModifyTableState *mtstate = resultRelInfo->ri_ModifyTableState;
+ ResultRelInfo *resultRelInfo = (ResultRelInfo *) lfirst(l1);
+ ModifyTableState *mtstate = (ModifyTableState *) lfirst(l2);
Assert(mtstate);
ExecBatchInsert(mtstate, resultRelInfo,
@@ -1236,7 +1242,9 @@ ExecPendingInserts(EState *estate)
}
list_free(estate->es_insert_pending_result_relations);
+ list_free(estate->es_insert_pending_modifytables);
estate->es_insert_pending_result_relations = NIL;
+ estate->es_insert_pending_modifytables = NIL;
}
/*
@@ -4342,13 +4350,6 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
}
else
resultRelInfo->ri_BatchSize = 1;
-
- /*
- * If doing batch insert, setup back-link so we can easily find the
- * mtstate again.
- */
- if (resultRelInfo->ri_BatchSize > 1)
- resultRelInfo->ri_ModifyTableState = mtstate;
}
/*