diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2022-04-20 11:18:04 +0200 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2022-04-20 11:18:04 +0200 |
commit | a87e75956926f966d90bdd1a6bd495cf59cdc3ad (patch) | |
tree | 005f76e2586ccfe730df65fcf99f330586f99ddc /src/backend/executor/nodeModifyTable.c | |
parent | 3dcc6bf4068a29be2bebee80bb919f8057af0fd9 (diff) | |
download | postgresql-a87e75956926f966d90bdd1a6bd495cf59cdc3ad.tar.gz postgresql-a87e75956926f966d90bdd1a6bd495cf59cdc3ad.zip |
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
Diffstat (limited to 'src/backend/executor/nodeModifyTable.c')
-rw-r--r-- | src/backend/executor/nodeModifyTable.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c index 0de6abd5bb8..982acfdad98 100644 --- a/src/backend/executor/nodeModifyTable.c +++ b/src/backend/executor/nodeModifyTable.c @@ -116,12 +116,6 @@ typedef struct ModifyTableContext * cross-partition UPDATE */ TupleTableSlot *cpUpdateReturningSlot; - - /* - * Lock mode to acquire on the latest tuple version before performing - * EvalPlanQual on it - */ - LockTupleMode lockmode; } ModifyTableContext; /* @@ -132,6 +126,12 @@ typedef struct UpdateContext bool updated; /* did UPDATE actually occur? */ bool updateIndexes; /* index update required? */ 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; @@ -1971,7 +1971,7 @@ lreplace:; estate->es_snapshot, estate->es_crosscheck_snapshot, true /* wait for commit */ , - &context->tmfd, &context->lockmode, + &context->tmfd, &updateCxt->lockmode, &updateCxt->updateIndexes); if (result == TM_Ok) updateCxt->updated = true; @@ -2251,7 +2251,7 @@ redo_act: result = table_tuple_lock(resultRelationDesc, tupleid, estate->es_snapshot, inputslot, estate->es_output_cid, - context->lockmode, LockWaitBlock, + updateCxt.lockmode, LockWaitBlock, TUPLE_LOCK_FLAG_FIND_LAST_VERSION, &context->tmfd); @@ -3557,8 +3557,6 @@ ExecModifyTable(PlanState *pstate) { EvalPlanQualSetSlot(&node->mt_epqstate, context.planSlot); - context.lockmode = 0; - ExecMerge(&context, node->resultRelInfo, NULL, node->canSetTag); continue; /* no RETURNING support yet */ } @@ -3637,8 +3635,6 @@ ExecModifyTable(PlanState *pstate) { EvalPlanQualSetSlot(&node->mt_epqstate, context.planSlot); - context.lockmode = 0; - ExecMerge(&context, node->resultRelInfo, NULL, node->canSetTag); continue; /* no RETURNING support yet */ } @@ -3694,9 +3690,6 @@ ExecModifyTable(PlanState *pstate) } } - /* complete context setup */ - context.lockmode = 0; - switch (operation) { case CMD_INSERT: |