@@ -263,8 +263,6 @@ static TupleTableSlot *
263263ExecInsert (ModifyTableState * mtstate ,
264264 TupleTableSlot * slot ,
265265 TupleTableSlot * planSlot ,
266- List * arbiterIndexes ,
267- OnConflictAction onconflict ,
268266 EState * estate ,
269267 bool canSetTag )
270268{
@@ -275,6 +273,8 @@ ExecInsert(ModifyTableState *mtstate,
275273 List * recheckIndexes = NIL ;
276274 TupleTableSlot * result = NULL ;
277275 TransitionCaptureState * 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,
365365 else
366366 {
367367 WCOKind 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,
420420 uint32 specToken ;
421421 ItemPointerData conflictTid ;
422422 bool 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,
537540 if (resultRelInfo -> ri_NumIndices > 0 )
538541 recheckIndexes = ExecInsertIndexTuples (slot , & (tuple -> t_self ),
539542 estate , false, NULL ,
540- arbiterIndexes );
543+ NIL );
541544 }
542545 }
543546
@@ -1124,8 +1127,8 @@ lreplace:;
11241127 slot = ExecPrepareTupleRouting (mtstate , estate , proute ,
11251128 mtstate -> 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. */
11311134 estate -> 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 ;
14901494 ResultRelInfo * resultRelInfo = node -> resultRelInfo ;
14911495
14921496 /*
@@ -1501,7 +1505,7 @@ fireBSTriggers(ModifyTableState *node)
15011505 {
15021506 case CMD_INSERT :
15031507 ExecBSInsertTriggers (node -> ps .state , resultRelInfo );
1504- if (node -> mt_onconflict == ONCONFLICT_UPDATE )
1508+ if (plan -> onConflictAction == ONCONFLICT_UPDATE )
15051509 ExecBSUpdateTriggers (node -> ps .state ,
15061510 resultRelInfo );
15071511 break ;
@@ -1545,12 +1549,13 @@ getTargetResultRelInfo(ModifyTableState *node)
15451549static void
15461550fireASTriggers (ModifyTableState * node )
15471551{
1552+ ModifyTable * plan = (ModifyTable * ) node -> ps .plan ;
15481553 ResultRelInfo * resultRelInfo = getTargetResultRelInfo (node );
15491554
15501555 switch (node -> operation )
15511556 {
15521557 case CMD_INSERT :
1553- if (node -> mt_onconflict == ONCONFLICT_UPDATE )
1558+ if (plan -> onConflictAction == ONCONFLICT_UPDATE )
15541559 ExecASUpdateTriggers (node -> ps .state ,
15551560 resultRelInfo ,
15561561 node -> 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 ;
15811587 ResultRelInfo * targetRelInfo = getTargetResultRelInfo (mtstate );
15821588
15831589 /* Check for transition tables on the directly targeted relation. */
15841590 mtstate -> mt_transition_capture =
15851591 MakeTransitionCaptureState (targetRelInfo -> ri_TrigDesc ,
15861592 RelationGetRelid (targetRelInfo -> ri_RelationDesc ),
15871593 mtstate -> operation );
1588- if (mtstate -> operation == CMD_INSERT &&
1589- mtstate -> mt_onconflict == ONCONFLICT_UPDATE )
1594+ if (plan -> operation == CMD_INSERT &&
1595+ plan -> onConflictAction == ONCONFLICT_UPDATE )
15901596 mtstate -> mt_oc_transition_capture =
15911597 MakeTransitionCaptureState (targetRelInfo -> ri_TrigDesc ,
15921598 RelationGetRelid (targetRelInfo -> ri_RelationDesc ),
@@ -2064,7 +2070,6 @@ ExecModifyTable(PlanState *pstate)
20642070 slot = ExecPrepareTupleRouting (node , estate , proute ,
20652071 resultRelInfo , slot );
20662072 slot = ExecInsert (node , slot , planSlot ,
2067- node -> mt_arbiterindexes , node -> mt_onconflict ,
20682073 estate , node -> canSetTag );
20692074 /* Revert ExecPrepareTupleRouting's state change. */
20702075 if (proute )
@@ -2151,8 +2156,6 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
21512156
21522157 mtstate -> mt_arowmarks = (List * * ) palloc0 (sizeof (List * ) * nplans );
21532158 mtstate -> 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 */
21582161 EvalPlanQualInit (& mtstate -> mt_epqstate , estate , NULL , NIL , node -> epqParam );
@@ -2195,7 +2198,8 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
21952198 if (resultRelInfo -> ri_RelationDesc -> rd_rel -> relhasindex &&
21962199 operation != CMD_DELETE &&
21972200 resultRelInfo -> 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
0 commit comments