Skip to content

Commit a87e759

Browse files
committed
Move ModifyTableContext->lockmode to UpdateContext
Should have been done this way to start with, but I failed to notice This way we avoid some pointless initialization, and better contains the variable to exist in the scope where it is really used. Reviewed-by: Michaël Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/202204191345.qerjy3kxi3eb@alvherre.pgsql
1 parent 3dcc6bf commit a87e759

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

src/backend/executor/nodeModifyTable.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,6 @@ typedef struct ModifyTableContext
116116
* cross-partition UPDATE
117117
*/
118118
TupleTableSlot *cpUpdateReturningSlot;
119-
120-
/*
121-
* Lock mode to acquire on the latest tuple version before performing
122-
* EvalPlanQual on it
123-
*/
124-
LockTupleMode lockmode;
125119
} ModifyTableContext;
126120

127121
/*
@@ -132,6 +126,12 @@ typedef struct UpdateContext
132126
bool updated; /* did UPDATE actually occur? */
133127
bool updateIndexes; /* index update required? */
134128
bool crossPartUpdate; /* was it a cross-partition update? */
129+
130+
/*
131+
* Lock mode to acquire on the latest tuple version before performing
132+
* EvalPlanQual on it
133+
*/
134+
LockTupleMode lockmode;
135135
} UpdateContext;
136136

137137

@@ -1971,7 +1971,7 @@ lreplace:;
19711971
estate->es_snapshot,
19721972
estate->es_crosscheck_snapshot,
19731973
true /* wait for commit */ ,
1974-
&context->tmfd, &context->lockmode,
1974+
&context->tmfd, &updateCxt->lockmode,
19751975
&updateCxt->updateIndexes);
19761976
if (result == TM_Ok)
19771977
updateCxt->updated = true;
@@ -2251,7 +2251,7 @@ ExecUpdate(ModifyTableContext *context, ResultRelInfo *resultRelInfo,
22512251
result = table_tuple_lock(resultRelationDesc, tupleid,
22522252
estate->es_snapshot,
22532253
inputslot, estate->es_output_cid,
2254-
context->lockmode, LockWaitBlock,
2254+
updateCxt.lockmode, LockWaitBlock,
22552255
TUPLE_LOCK_FLAG_FIND_LAST_VERSION,
22562256
&context->tmfd);
22572257

@@ -3557,8 +3557,6 @@ ExecModifyTable(PlanState *pstate)
35573557
{
35583558
EvalPlanQualSetSlot(&node->mt_epqstate, context.planSlot);
35593559

3560-
context.lockmode = 0;
3561-
35623560
ExecMerge(&context, node->resultRelInfo, NULL, node->canSetTag);
35633561
continue; /* no RETURNING support yet */
35643562
}
@@ -3637,8 +3635,6 @@ ExecModifyTable(PlanState *pstate)
36373635
{
36383636
EvalPlanQualSetSlot(&node->mt_epqstate, context.planSlot);
36393637

3640-
context.lockmode = 0;
3641-
36423638
ExecMerge(&context, node->resultRelInfo, NULL, node->canSetTag);
36433639
continue; /* no RETURNING support yet */
36443640
}
@@ -3694,9 +3690,6 @@ ExecModifyTable(PlanState *pstate)
36943690
}
36953691
}
36963692

3697-
/* complete context setup */
3698-
context.lockmode = 0;
3699-
37003693
switch (operation)
37013694
{
37023695
case CMD_INSERT:

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