ExecInsert(ModifyTableState *mtstate,
TupleTableSlot *slot,
TupleTableSlot *planSlot,
- List *arbiterIndexes,
- OnConflictAction onconflict,
EState *estate,
bool canSetTag)
{
List *recheckIndexes = NIL;
TupleTableSlot *result = NULL;
TransitionCaptureState *ar_insert_trig_tcs;
+ ModifyTable *node = (ModifyTable *) mtstate->ps.plan;
+ OnConflictAction onconflict = node->onConflictAction;
/*
* get the heap tuple out of the tuple table slot, making sure we have a
else
{
WCOKind wco_kind;
+ bool check_partition_constr;
/*
* We always check the partition constraint, including when the tuple
* trigger might modify the tuple such that the partition constraint
* is no longer satisfied, so we need to check in that case.
*/
- bool check_partition_constr =
- (resultRelInfo->ri_PartitionCheck != NIL);
+ check_partition_constr = (resultRelInfo->ri_PartitionCheck != NIL);
/*
* Constraints might reference the tableoid column, so initialize
uint32 specToken;
ItemPointerData conflictTid;
bool specConflict;
+ List *arbiterIndexes;
+
+ arbiterIndexes = node->arbiterIndexes;
/*
* Do a non-conclusive check for conflicts first.
if (resultRelInfo->ri_NumIndices > 0)
recheckIndexes = ExecInsertIndexTuples(slot, &(tuple->t_self),
estate, false, NULL,
- arbiterIndexes);
+ NIL);
}
}
slot = ExecPrepareTupleRouting(mtstate, estate, proute,
mtstate->rootResultRelInfo, slot);
- ret_slot = ExecInsert(mtstate, slot, planSlot, NULL,
- ONCONFLICT_NONE, estate, canSetTag);
+ ret_slot = ExecInsert(mtstate, slot, planSlot,
+ estate, canSetTag);
/* Revert ExecPrepareTupleRouting's node change. */
estate->es_result_relation_info = resultRelInfo;
static void
fireBSTriggers(ModifyTableState *node)
{
+ ModifyTable *plan = (ModifyTable *) node->ps.plan;
ResultRelInfo *resultRelInfo = node->resultRelInfo;
/*
{
case CMD_INSERT:
ExecBSInsertTriggers(node->ps.state, resultRelInfo);
- if (node->mt_onconflict == ONCONFLICT_UPDATE)
+ if (plan->onConflictAction == ONCONFLICT_UPDATE)
ExecBSUpdateTriggers(node->ps.state,
resultRelInfo);
break;
static void
fireASTriggers(ModifyTableState *node)
{
+ ModifyTable *plan = (ModifyTable *) node->ps.plan;
ResultRelInfo *resultRelInfo = getTargetResultRelInfo(node);
switch (node->operation)
{
case CMD_INSERT:
- if (node->mt_onconflict == ONCONFLICT_UPDATE)
+ if (plan->onConflictAction == ONCONFLICT_UPDATE)
ExecASUpdateTriggers(node->ps.state,
resultRelInfo,
node->mt_oc_transition_capture);
static void
ExecSetupTransitionCaptureState(ModifyTableState *mtstate, EState *estate)
{
+ ModifyTable *plan = (ModifyTable *) mtstate->ps.plan;
ResultRelInfo *targetRelInfo = getTargetResultRelInfo(mtstate);
/* Check for transition tables on the directly targeted relation. */
MakeTransitionCaptureState(targetRelInfo->ri_TrigDesc,
RelationGetRelid(targetRelInfo->ri_RelationDesc),
mtstate->operation);
- if (mtstate->operation == CMD_INSERT &&
- mtstate->mt_onconflict == ONCONFLICT_UPDATE)
+ if (plan->operation == CMD_INSERT &&
+ plan->onConflictAction == ONCONFLICT_UPDATE)
mtstate->mt_oc_transition_capture =
MakeTransitionCaptureState(targetRelInfo->ri_TrigDesc,
RelationGetRelid(targetRelInfo->ri_RelationDesc),
slot = ExecPrepareTupleRouting(node, estate, proute,
resultRelInfo, slot);
slot = ExecInsert(node, slot, planSlot,
- node->mt_arbiterindexes, node->mt_onconflict,
estate, node->canSetTag);
/* Revert ExecPrepareTupleRouting's state change. */
if (proute)
mtstate->mt_arowmarks = (List **) palloc0(sizeof(List *) * nplans);
mtstate->mt_nplans = nplans;
- mtstate->mt_onconflict = node->onConflictAction;
- mtstate->mt_arbiterindexes = node->arbiterIndexes;
/* set up epqstate with dummy subplan data for the moment */
EvalPlanQualInit(&mtstate->mt_epqstate, estate, NULL, NIL, node->epqParam);
if (resultRelInfo->ri_RelationDesc->rd_rel->relhasindex &&
operation != CMD_DELETE &&
resultRelInfo->ri_IndexRelationDescs == NULL)
- ExecOpenIndices(resultRelInfo, mtstate->mt_onconflict != ONCONFLICT_NONE);
+ ExecOpenIndices(resultRelInfo,
+ node->onConflictAction != ONCONFLICT_NONE);
/*
* If this is an UPDATE and a BEFORE UPDATE trigger is present, the