ResultRelInfo *resultRelInfo;
    PlanState  *subplanstate;
    TupleTableSlot *slot;
-   TupleTableSlot *planSlot;
    TupleTableSlot *oldSlot;
    ItemPointerData tuple_ctid;
    HeapTupleData oldtupdata;
        if (pstate->ps_ExprContext)
            ResetExprContext(pstate->ps_ExprContext);
 
-       planSlot = ExecProcNode(subplanstate);
+       context.planSlot = ExecProcNode(subplanstate);
 
        /* No more tuples to process? */
-       if (TupIsNull(planSlot))
+       if (TupIsNull(context.planSlot))
            break;
 
        /*
            bool        isNull;
            Oid         resultoid;
 
-           datum = ExecGetJunkAttribute(planSlot, node->mt_resultOidAttno,
+           datum = ExecGetJunkAttribute(context.planSlot, node->mt_resultOidAttno,
                                         &isNull);
            if (isNull)
            {
                 */
                if (operation == CMD_MERGE)
                {
-                   EvalPlanQualSetSlot(&node->mt_epqstate, planSlot);
+                   EvalPlanQualSetSlot(&node->mt_epqstate, context.planSlot);
 
-                   context.planSlot = planSlot;
                    context.lockmode = 0;
 
                    ExecMerge(&context, node->resultRelInfo, NULL, node->canSetTag);
             * ExecProcessReturning by IterateDirectModify, so no need to
             * provide it here.
             */
-           slot = ExecProcessReturning(resultRelInfo, NULL, planSlot);
+           slot = ExecProcessReturning(resultRelInfo, NULL, context.planSlot);
 
            return slot;
        }
 
-       EvalPlanQualSetSlot(&node->mt_epqstate, planSlot);
-       slot = planSlot;
+       EvalPlanQualSetSlot(&node->mt_epqstate, context.planSlot);
+       slot = context.planSlot;
 
        tupleid = NULL;
        oldtuple = NULL;
                {
                    if (operation == CMD_MERGE)
                    {
-                       EvalPlanQualSetSlot(&node->mt_epqstate, planSlot);
+                       EvalPlanQualSetSlot(&node->mt_epqstate, context.planSlot);
 
-                       context.planSlot = planSlot;
                        context.lockmode = 0;
 
                        ExecMerge(&context, node->resultRelInfo, NULL, node->canSetTag);
        }
 
        /* complete context setup */
-       context.planSlot = planSlot;
        context.lockmode = 0;
 
        switch (operation)
                /* Initialize projection info if first time for this table */
                if (unlikely(!resultRelInfo->ri_projectNewInfoValid))
                    ExecInitInsertProjection(node, resultRelInfo);
-               slot = ExecGetInsertNewTuple(resultRelInfo, planSlot);
+               slot = ExecGetInsertNewTuple(resultRelInfo, context.planSlot);
                slot = ExecInsert(&context, resultRelInfo, slot,
                                  node->canSetTag, NULL, NULL);
                break;
                                                       oldSlot))
                        elog(ERROR, "failed to fetch tuple being updated");
                }
-               slot = internalGetUpdateNewTuple(resultRelInfo, planSlot,
+               slot = internalGetUpdateNewTuple(resultRelInfo, context.planSlot,
                                                 oldSlot, NULL);
                context.GetUpdateNewTuple = internalGetUpdateNewTuple;
                context.relaction = NULL;