@@ -263,8 +263,6 @@ static TupleTableSlot *
263263ExecInsert (ModifyTableState * mtstate ,
264264TupleTableSlot * slot ,
265265TupleTableSlot * planSlot ,
266- List * arbiterIndexes ,
267- OnConflictAction onconflict ,
268266EState * estate ,
269267bool canSetTag )
270268{
@@ -275,6 +273,8 @@ ExecInsert(ModifyTableState *mtstate,
275273List * recheckIndexes = NIL ;
276274TupleTableSlot * result = NULL ;
277275TransitionCaptureState * ar_insert_trig_tcs ;
276+ ModifyTable * node = (ModifyTable * )mtstate -> ps .plan ;
277+ OnConflictAction onconflict = node -> onConflictAction ;
278278
279279/*
280280 * get the heap tuple out of the tuple table slot, making sure we have a
@@ -365,6 +365,7 @@ ExecInsert(ModifyTableState *mtstate,
365365else
366366{
367367WCOKind wco_kind ;
368+ bool check_partition_constr ;
368369
369370/*
370371 * We always check the partition constraint, including when the tuple
@@ -373,8 +374,7 @@ ExecInsert(ModifyTableState *mtstate,
373374 * trigger might modify the tuple such that the partition constraint
374375 * is no longer satisfied, so we need to check in that case.
375376 */
376- bool check_partition_constr =
377- (resultRelInfo -> ri_PartitionCheck != NIL );
377+ check_partition_constr = (resultRelInfo -> ri_PartitionCheck != NIL );
378378
379379/*
380380 * Constraints might reference the tableoid column, so initialize
@@ -420,6 +420,9 @@ ExecInsert(ModifyTableState *mtstate,
420420uint32 specToken ;
421421ItemPointerData conflictTid ;
422422bool specConflict ;
423+ List * arbiterIndexes ;
424+
425+ arbiterIndexes = node -> arbiterIndexes ;
423426
424427/*
425428 * Do a non-conclusive check for conflicts first.
@@ -537,7 +540,7 @@ ExecInsert(ModifyTableState *mtstate,
537540if (resultRelInfo -> ri_NumIndices > 0 )
538541recheckIndexes = ExecInsertIndexTuples (slot ,& (tuple -> t_self ),
539542estate , false,NULL ,
540- arbiterIndexes );
543+ NIL );
541544}
542545}
543546
@@ -1124,8 +1127,8 @@ lreplace:;
11241127slot = ExecPrepareTupleRouting (mtstate ,estate ,proute ,
11251128mtstate -> rootResultRelInfo ,slot );
11261129
1127- ret_slot = ExecInsert (mtstate ,slot ,planSlot ,NULL ,
1128- ONCONFLICT_NONE , estate ,canSetTag );
1130+ ret_slot = ExecInsert (mtstate ,slot ,planSlot ,
1131+ estate ,canSetTag );
11291132
11301133/* Revert ExecPrepareTupleRouting's node change. */
11311134estate -> es_result_relation_info = resultRelInfo ;
@@ -1487,6 +1490,7 @@ ExecOnConflictUpdate(ModifyTableState *mtstate,
14871490static void
14881491fireBSTriggers (ModifyTableState * node )
14891492{
1493+ ModifyTable * plan = (ModifyTable * )node -> ps .plan ;
14901494ResultRelInfo * resultRelInfo = node -> resultRelInfo ;
14911495
14921496/*
@@ -1501,7 +1505,7 @@ fireBSTriggers(ModifyTableState *node)
15011505{
15021506case CMD_INSERT :
15031507ExecBSInsertTriggers (node -> ps .state ,resultRelInfo );
1504- if (node -> mt_onconflict == ONCONFLICT_UPDATE )
1508+ if (plan -> onConflictAction == ONCONFLICT_UPDATE )
15051509ExecBSUpdateTriggers (node -> ps .state ,
15061510resultRelInfo );
15071511break ;
@@ -1545,12 +1549,13 @@ getTargetResultRelInfo(ModifyTableState *node)
15451549static void
15461550fireASTriggers (ModifyTableState * node )
15471551{
1552+ ModifyTable * plan = (ModifyTable * )node -> ps .plan ;
15481553ResultRelInfo * resultRelInfo = getTargetResultRelInfo (node );
15491554
15501555switch (node -> operation )
15511556{
15521557case CMD_INSERT :
1553- if (node -> mt_onconflict == ONCONFLICT_UPDATE )
1558+ if (plan -> onConflictAction == ONCONFLICT_UPDATE )
15541559ExecASUpdateTriggers (node -> ps .state ,
15551560resultRelInfo ,
15561561node -> mt_oc_transition_capture );
@@ -1578,15 +1583,16 @@ fireASTriggers(ModifyTableState *node)
15781583static void
15791584ExecSetupTransitionCaptureState (ModifyTableState * mtstate ,EState * estate )
15801585{
1586+ ModifyTable * plan = (ModifyTable * )mtstate -> ps .plan ;
15811587ResultRelInfo * targetRelInfo = getTargetResultRelInfo (mtstate );
15821588
15831589/* Check for transition tables on the directly targeted relation. */
15841590mtstate -> mt_transition_capture =
15851591MakeTransitionCaptureState (targetRelInfo -> ri_TrigDesc ,
15861592RelationGetRelid (targetRelInfo -> ri_RelationDesc ),
15871593mtstate -> operation );
1588- if (mtstate -> operation == CMD_INSERT &&
1589- mtstate -> mt_onconflict == ONCONFLICT_UPDATE )
1594+ if (plan -> operation == CMD_INSERT &&
1595+ plan -> onConflictAction == ONCONFLICT_UPDATE )
15901596mtstate -> mt_oc_transition_capture =
15911597MakeTransitionCaptureState (targetRelInfo -> ri_TrigDesc ,
15921598RelationGetRelid (targetRelInfo -> ri_RelationDesc ),
@@ -2064,7 +2070,6 @@ ExecModifyTable(PlanState *pstate)
20642070slot = ExecPrepareTupleRouting (node ,estate ,proute ,
20652071resultRelInfo ,slot );
20662072slot = ExecInsert (node ,slot ,planSlot ,
2067- node -> mt_arbiterindexes ,node -> mt_onconflict ,
20682073estate ,node -> canSetTag );
20692074/* Revert ExecPrepareTupleRouting's state change. */
20702075if (proute )
@@ -2151,8 +2156,6 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
21512156
21522157mtstate -> mt_arowmarks = (List * * )palloc0 (sizeof (List * )* nplans );
21532158mtstate -> mt_nplans = nplans ;
2154- mtstate -> mt_onconflict = node -> onConflictAction ;
2155- mtstate -> mt_arbiterindexes = node -> arbiterIndexes ;
21562159
21572160/* set up epqstate with dummy subplan data for the moment */
21582161EvalPlanQualInit (& mtstate -> mt_epqstate ,estate ,NULL ,NIL ,node -> epqParam );
@@ -2195,7 +2198,8 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
21952198if (resultRelInfo -> ri_RelationDesc -> rd_rel -> relhasindex &&
21962199operation != CMD_DELETE &&
21972200resultRelInfo -> ri_IndexRelationDescs == NULL )
2198- ExecOpenIndices (resultRelInfo ,mtstate -> mt_onconflict != ONCONFLICT_NONE );
2201+ ExecOpenIndices (resultRelInfo ,
2202+ node -> onConflictAction != ONCONFLICT_NONE );
21992203
22002204/*
22012205 * If this is an UPDATE and a BEFORE UPDATE trigger is present, the