Skip to content

Commit 3dcc6bf

Browse files
committed
ExecModifyTable: use context.planSlot instead of planSlot
There's no reason to keep a separate local variable when we have a place for it elsewhere. This allows to simplify some code. Reviewed-by: Michaël Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/202204191345.qerjy3kxi3eb@alvherre.pgsql
1 parent 74547b9 commit 3dcc6bf

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/backend/executor/nodeModifyTable.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3452,7 +3452,6 @@ ExecModifyTable(PlanState *pstate)
34523452
ResultRelInfo *resultRelInfo;
34533453
PlanState *subplanstate;
34543454
TupleTableSlot *slot;
3455-
TupleTableSlot *planSlot;
34563455
TupleTableSlot *oldSlot;
34573456
ItemPointerData tuple_ctid;
34583457
HeapTupleData oldtupdata;
@@ -3525,10 +3524,10 @@ ExecModifyTable(PlanState *pstate)
35253524
if (pstate->ps_ExprContext)
35263525
ResetExprContext(pstate->ps_ExprContext);
35273526

3528-
planSlot = ExecProcNode(subplanstate);
3527+
context.planSlot = ExecProcNode(subplanstate);
35293528

35303529
/* No more tuples to process? */
3531-
if (TupIsNull(planSlot))
3530+
if (TupIsNull(context.planSlot))
35323531
break;
35333532

35343533
/*
@@ -3542,7 +3541,7 @@ ExecModifyTable(PlanState *pstate)
35423541
bool isNull;
35433542
Oid resultoid;
35443543

3545-
datum = ExecGetJunkAttribute(planSlot, node->mt_resultOidAttno,
3544+
datum = ExecGetJunkAttribute(context.planSlot, node->mt_resultOidAttno,
35463545
&isNull);
35473546
if (isNull)
35483547
{
@@ -3556,9 +3555,8 @@ ExecModifyTable(PlanState *pstate)
35563555
*/
35573556
if (operation == CMD_MERGE)
35583557
{
3559-
EvalPlanQualSetSlot(&node->mt_epqstate, planSlot);
3558+
EvalPlanQualSetSlot(&node->mt_epqstate, context.planSlot);
35603559

3561-
context.planSlot = planSlot;
35623560
context.lockmode = 0;
35633561

35643562
ExecMerge(&context, node->resultRelInfo, NULL, node->canSetTag);
@@ -3589,13 +3587,13 @@ ExecModifyTable(PlanState *pstate)
35893587
* ExecProcessReturning by IterateDirectModify, so no need to
35903588
* provide it here.
35913589
*/
3592-
slot = ExecProcessReturning(resultRelInfo, NULL, planSlot);
3590+
slot = ExecProcessReturning(resultRelInfo, NULL, context.planSlot);
35933591

35943592
return slot;
35953593
}
35963594

3597-
EvalPlanQualSetSlot(&node->mt_epqstate, planSlot);
3598-
slot = planSlot;
3595+
EvalPlanQualSetSlot(&node->mt_epqstate, context.planSlot);
3596+
slot = context.planSlot;
35993597

36003598
tupleid = NULL;
36013599
oldtuple = NULL;
@@ -3637,9 +3635,8 @@ ExecModifyTable(PlanState *pstate)
36373635
{
36383636
if (operation == CMD_MERGE)
36393637
{
3640-
EvalPlanQualSetSlot(&node->mt_epqstate, planSlot);
3638+
EvalPlanQualSetSlot(&node->mt_epqstate, context.planSlot);
36413639

3642-
context.planSlot = planSlot;
36433640
context.lockmode = 0;
36443641

36453642
ExecMerge(&context, node->resultRelInfo, NULL, node->canSetTag);
@@ -3698,7 +3695,6 @@ ExecModifyTable(PlanState *pstate)
36983695
}
36993696

37003697
/* complete context setup */
3701-
context.planSlot = planSlot;
37023698
context.lockmode = 0;
37033699

37043700
switch (operation)
@@ -3707,7 +3703,7 @@ ExecModifyTable(PlanState *pstate)
37073703
/* Initialize projection info if first time for this table */
37083704
if (unlikely(!resultRelInfo->ri_projectNewInfoValid))
37093705
ExecInitInsertProjection(node, resultRelInfo);
3710-
slot = ExecGetInsertNewTuple(resultRelInfo, planSlot);
3706+
slot = ExecGetInsertNewTuple(resultRelInfo, context.planSlot);
37113707
slot = ExecInsert(&context, resultRelInfo, slot,
37123708
node->canSetTag, NULL, NULL);
37133709
break;
@@ -3737,7 +3733,7 @@ ExecModifyTable(PlanState *pstate)
37373733
oldSlot))
37383734
elog(ERROR, "failed to fetch tuple being updated");
37393735
}
3740-
slot = internalGetUpdateNewTuple(resultRelInfo, planSlot,
3736+
slot = internalGetUpdateNewTuple(resultRelInfo, context.planSlot,
37413737
oldSlot, NULL);
37423738
context.GetUpdateNewTuple = internalGetUpdateNewTuple;
37433739
context.relaction = NULL;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy