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
This commit is contained in:
parent
3dcc6bf406
commit
a87e759569
|
@ -116,12 +116,6 @@ typedef struct ModifyTableContext
|
||||||
* cross-partition UPDATE
|
* cross-partition UPDATE
|
||||||
*/
|
*/
|
||||||
TupleTableSlot *cpUpdateReturningSlot;
|
TupleTableSlot *cpUpdateReturningSlot;
|
||||||
|
|
||||||
/*
|
|
||||||
* Lock mode to acquire on the latest tuple version before performing
|
|
||||||
* EvalPlanQual on it
|
|
||||||
*/
|
|
||||||
LockTupleMode lockmode;
|
|
||||||
} ModifyTableContext;
|
} ModifyTableContext;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -132,6 +126,12 @@ typedef struct UpdateContext
|
||||||
bool updated; /* did UPDATE actually occur? */
|
bool updated; /* did UPDATE actually occur? */
|
||||||
bool updateIndexes; /* index update required? */
|
bool updateIndexes; /* index update required? */
|
||||||
bool crossPartUpdate; /* was it a cross-partition update? */
|
bool crossPartUpdate; /* was it a cross-partition update? */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Lock mode to acquire on the latest tuple version before performing
|
||||||
|
* EvalPlanQual on it
|
||||||
|
*/
|
||||||
|
LockTupleMode lockmode;
|
||||||
} UpdateContext;
|
} UpdateContext;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1971,7 +1971,7 @@ lreplace:;
|
||||||
estate->es_snapshot,
|
estate->es_snapshot,
|
||||||
estate->es_crosscheck_snapshot,
|
estate->es_crosscheck_snapshot,
|
||||||
true /* wait for commit */ ,
|
true /* wait for commit */ ,
|
||||||
&context->tmfd, &context->lockmode,
|
&context->tmfd, &updateCxt->lockmode,
|
||||||
&updateCxt->updateIndexes);
|
&updateCxt->updateIndexes);
|
||||||
if (result == TM_Ok)
|
if (result == TM_Ok)
|
||||||
updateCxt->updated = true;
|
updateCxt->updated = true;
|
||||||
|
@ -2251,7 +2251,7 @@ redo_act:
|
||||||
result = table_tuple_lock(resultRelationDesc, tupleid,
|
result = table_tuple_lock(resultRelationDesc, tupleid,
|
||||||
estate->es_snapshot,
|
estate->es_snapshot,
|
||||||
inputslot, estate->es_output_cid,
|
inputslot, estate->es_output_cid,
|
||||||
context->lockmode, LockWaitBlock,
|
updateCxt.lockmode, LockWaitBlock,
|
||||||
TUPLE_LOCK_FLAG_FIND_LAST_VERSION,
|
TUPLE_LOCK_FLAG_FIND_LAST_VERSION,
|
||||||
&context->tmfd);
|
&context->tmfd);
|
||||||
|
|
||||||
|
@ -3557,8 +3557,6 @@ ExecModifyTable(PlanState *pstate)
|
||||||
{
|
{
|
||||||
EvalPlanQualSetSlot(&node->mt_epqstate, context.planSlot);
|
EvalPlanQualSetSlot(&node->mt_epqstate, context.planSlot);
|
||||||
|
|
||||||
context.lockmode = 0;
|
|
||||||
|
|
||||||
ExecMerge(&context, node->resultRelInfo, NULL, node->canSetTag);
|
ExecMerge(&context, node->resultRelInfo, NULL, node->canSetTag);
|
||||||
continue; /* no RETURNING support yet */
|
continue; /* no RETURNING support yet */
|
||||||
}
|
}
|
||||||
|
@ -3637,8 +3635,6 @@ ExecModifyTable(PlanState *pstate)
|
||||||
{
|
{
|
||||||
EvalPlanQualSetSlot(&node->mt_epqstate, context.planSlot);
|
EvalPlanQualSetSlot(&node->mt_epqstate, context.planSlot);
|
||||||
|
|
||||||
context.lockmode = 0;
|
|
||||||
|
|
||||||
ExecMerge(&context, node->resultRelInfo, NULL, node->canSetTag);
|
ExecMerge(&context, node->resultRelInfo, NULL, node->canSetTag);
|
||||||
continue; /* no RETURNING support yet */
|
continue; /* no RETURNING support yet */
|
||||||
}
|
}
|
||||||
|
@ -3694,9 +3690,6 @@ ExecModifyTable(PlanState *pstate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* complete context setup */
|
|
||||||
context.lockmode = 0;
|
|
||||||
|
|
||||||
switch (operation)
|
switch (operation)
|
||||||
{
|
{
|
||||||
case CMD_INSERT:
|
case CMD_INSERT:
|
||||||
|
|
Loading…
Reference in New Issue