Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitee0a1fc

Browse files
committed
Remove unnecessary members from ModifyTableState and ExecInsert
These values can be obtained from the ModifyTable node which is alreadya part of both the ModifyTableState and ExecInsert.Author: Álvaro Herrera, Amit LangoteReviewed-by: Peter GeogheganDiscussion:https://postgr.es/m/20180316151303.rml2p5wffn3o6qy6@alvherre.pgsql
1 parent839a8eb commitee0a1fc

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

‎src/backend/executor/execPartition.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ ExecInitPartitionInfo(ModifyTableState *mtstate,
363363
if (partrel->rd_rel->relhasindex&&
364364
leaf_part_rri->ri_IndexRelationDescs==NULL)
365365
ExecOpenIndices(leaf_part_rri,
366-
(mtstate!=NULL&&
367-
mtstate->mt_onconflict!=ONCONFLICT_NONE));
366+
(node!=NULL&&
367+
node->onConflictAction!=ONCONFLICT_NONE));
368368

369369
/*
370370
* Build WITH CHECK OPTION constraints for the partition. Note that we

‎src/backend/executor/nodeModifyTable.c

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,6 @@ static TupleTableSlot *
263263
ExecInsert(ModifyTableState*mtstate,
264264
TupleTableSlot*slot,
265265
TupleTableSlot*planSlot,
266-
List*arbiterIndexes,
267-
OnConflictActiononconflict,
268266
EState*estate,
269267
boolcanSetTag)
270268
{
@@ -275,6 +273,8 @@ ExecInsert(ModifyTableState *mtstate,
275273
List*recheckIndexes=NIL;
276274
TupleTableSlot*result=NULL;
277275
TransitionCaptureState*ar_insert_trig_tcs;
276+
ModifyTable*node= (ModifyTable*)mtstate->ps.plan;
277+
OnConflictActiononconflict=node->onConflictAction;
278278

279279
/*
280280
* get the heap tuple out of the tuple table slot, making sure we have a
@@ -365,6 +365,7 @@ ExecInsert(ModifyTableState *mtstate,
365365
else
366366
{
367367
WCOKindwco_kind;
368+
boolcheck_partition_constr;
368369

369370
/*
370371
* We always check the partition constraint, including when the tuple
@@ -373,8 +374,7 @@ ExecInsert(ModifyTableState *mtstate,
373374
* trigger might modify the tuple such that the partition constraint
374375
* is no longer satisfied, so we need to check in that case.
375376
*/
376-
boolcheck_partition_constr=
377-
(resultRelInfo->ri_PartitionCheck!=NIL);
377+
check_partition_constr= (resultRelInfo->ri_PartitionCheck!=NIL);
378378

379379
/*
380380
* Constraints might reference the tableoid column, so initialize
@@ -420,6 +420,9 @@ ExecInsert(ModifyTableState *mtstate,
420420
uint32specToken;
421421
ItemPointerDataconflictTid;
422422
boolspecConflict;
423+
List*arbiterIndexes;
424+
425+
arbiterIndexes=node->arbiterIndexes;
423426

424427
/*
425428
* Do a non-conclusive check for conflicts first.
@@ -537,7 +540,7 @@ ExecInsert(ModifyTableState *mtstate,
537540
if (resultRelInfo->ri_NumIndices>0)
538541
recheckIndexes=ExecInsertIndexTuples(slot,&(tuple->t_self),
539542
estate, false,NULL,
540-
arbiterIndexes);
543+
NIL);
541544
}
542545
}
543546

@@ -1124,8 +1127,8 @@ lreplace:;
11241127
slot=ExecPrepareTupleRouting(mtstate,estate,proute,
11251128
mtstate->rootResultRelInfo,slot);
11261129

1127-
ret_slot=ExecInsert(mtstate,slot,planSlot,NULL,
1128-
ONCONFLICT_NONE,estate,canSetTag);
1130+
ret_slot=ExecInsert(mtstate,slot,planSlot,
1131+
estate,canSetTag);
11291132

11301133
/* Revert ExecPrepareTupleRouting's node change. */
11311134
estate->es_result_relation_info=resultRelInfo;
@@ -1487,6 +1490,7 @@ ExecOnConflictUpdate(ModifyTableState *mtstate,
14871490
staticvoid
14881491
fireBSTriggers(ModifyTableState*node)
14891492
{
1493+
ModifyTable*plan= (ModifyTable*)node->ps.plan;
14901494
ResultRelInfo*resultRelInfo=node->resultRelInfo;
14911495

14921496
/*
@@ -1501,7 +1505,7 @@ fireBSTriggers(ModifyTableState *node)
15011505
{
15021506
caseCMD_INSERT:
15031507
ExecBSInsertTriggers(node->ps.state,resultRelInfo);
1504-
if (node->mt_onconflict==ONCONFLICT_UPDATE)
1508+
if (plan->onConflictAction==ONCONFLICT_UPDATE)
15051509
ExecBSUpdateTriggers(node->ps.state,
15061510
resultRelInfo);
15071511
break;
@@ -1545,12 +1549,13 @@ getTargetResultRelInfo(ModifyTableState *node)
15451549
staticvoid
15461550
fireASTriggers(ModifyTableState*node)
15471551
{
1552+
ModifyTable*plan= (ModifyTable*)node->ps.plan;
15481553
ResultRelInfo*resultRelInfo=getTargetResultRelInfo(node);
15491554

15501555
switch (node->operation)
15511556
{
15521557
caseCMD_INSERT:
1553-
if (node->mt_onconflict==ONCONFLICT_UPDATE)
1558+
if (plan->onConflictAction==ONCONFLICT_UPDATE)
15541559
ExecASUpdateTriggers(node->ps.state,
15551560
resultRelInfo,
15561561
node->mt_oc_transition_capture);
@@ -1578,15 +1583,16 @@ fireASTriggers(ModifyTableState *node)
15781583
staticvoid
15791584
ExecSetupTransitionCaptureState(ModifyTableState*mtstate,EState*estate)
15801585
{
1586+
ModifyTable*plan= (ModifyTable*)mtstate->ps.plan;
15811587
ResultRelInfo*targetRelInfo=getTargetResultRelInfo(mtstate);
15821588

15831589
/* Check for transition tables on the directly targeted relation. */
15841590
mtstate->mt_transition_capture=
15851591
MakeTransitionCaptureState(targetRelInfo->ri_TrigDesc,
15861592
RelationGetRelid(targetRelInfo->ri_RelationDesc),
15871593
mtstate->operation);
1588-
if (mtstate->operation==CMD_INSERT&&
1589-
mtstate->mt_onconflict==ONCONFLICT_UPDATE)
1594+
if (plan->operation==CMD_INSERT&&
1595+
plan->onConflictAction==ONCONFLICT_UPDATE)
15901596
mtstate->mt_oc_transition_capture=
15911597
MakeTransitionCaptureState(targetRelInfo->ri_TrigDesc,
15921598
RelationGetRelid(targetRelInfo->ri_RelationDesc),
@@ -2064,7 +2070,6 @@ ExecModifyTable(PlanState *pstate)
20642070
slot=ExecPrepareTupleRouting(node,estate,proute,
20652071
resultRelInfo,slot);
20662072
slot=ExecInsert(node,slot,planSlot,
2067-
node->mt_arbiterindexes,node->mt_onconflict,
20682073
estate,node->canSetTag);
20692074
/* Revert ExecPrepareTupleRouting's state change. */
20702075
if (proute)
@@ -2151,8 +2156,6 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
21512156

21522157
mtstate->mt_arowmarks= (List**)palloc0(sizeof(List*)*nplans);
21532158
mtstate->mt_nplans=nplans;
2154-
mtstate->mt_onconflict=node->onConflictAction;
2155-
mtstate->mt_arbiterindexes=node->arbiterIndexes;
21562159

21572160
/* set up epqstate with dummy subplan data for the moment */
21582161
EvalPlanQualInit(&mtstate->mt_epqstate,estate,NULL,NIL,node->epqParam);
@@ -2195,7 +2198,8 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
21952198
if (resultRelInfo->ri_RelationDesc->rd_rel->relhasindex&&
21962199
operation!=CMD_DELETE&&
21972200
resultRelInfo->ri_IndexRelationDescs==NULL)
2198-
ExecOpenIndices(resultRelInfo,mtstate->mt_onconflict!=ONCONFLICT_NONE);
2201+
ExecOpenIndices(resultRelInfo,
2202+
node->onConflictAction!=ONCONFLICT_NONE);
21992203

22002204
/*
22012205
* If this is an UPDATE and a BEFORE UPDATE trigger is present, the

‎src/include/nodes/execnodes.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -989,9 +989,6 @@ typedef struct ModifyTableState
989989
List**mt_arowmarks;/* per-subplan ExecAuxRowMark lists */
990990
EPQStatemt_epqstate;/* for evaluating EvalPlanQual rechecks */
991991
boolfireBSTriggers;/* do we need to fire stmt triggers? */
992-
OnConflictActionmt_onconflict;/* ON CONFLICT type */
993-
List*mt_arbiterindexes;/* unique index OIDs to arbitrate taking
994-
* alt path */
995992
TupleTableSlot*mt_existing;/* slot to store existing target tuple in */
996993
List*mt_excludedtlist;/* the excluded pseudo relation's tlist */
997994
TupleTableSlot*mt_conflproj;/* CONFLICT ... SET ... projection target */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp