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

Commit1fdb7f9

Browse files
committed
expression eval: Don't redundantly keep track of AggState.
It's already tracked via ExprState->parent, so we don't need to alsoinclude it in ExprEvalStep. When that code originally was writtenExprState->parent didn't exist, but it since has been introduced in6719b23.Author: Andres FreundDiscussion:https://postgr.es/m/20191023163849.sosqbfs5yenocez3@alap3.anarazel.de
1 parent1ec7679 commit1fdb7f9

File tree

5 files changed

+20
-31
lines changed

5 files changed

+20
-31
lines changed

‎src/backend/executor/execExpr.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,6 @@ ExecInitExprRec(Expr *node, ExprState *state,
810810
elog(ERROR,"GroupingFunc found in non-Agg plan node");
811811

812812
scratch.opcode=EEOP_GROUPING_FUNC;
813-
scratch.d.grouping_func.parent= (AggState*)state->parent;
814813

815814
agg= (Agg*) (state->parent->plan);
816815

@@ -3050,7 +3049,6 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
30503049
else
30513050
scratch.opcode=EEOP_AGG_DESERIALIZE;
30523051

3053-
scratch.d.agg_deserialize.aggstate=aggstate;
30543052
scratch.d.agg_deserialize.fcinfo_data=ds_fcinfo;
30553053
scratch.d.agg_deserialize.jumpnull=-1;/* adjust later */
30563054
scratch.resvalue=&trans_fcinfo->args[argno+1].value;
@@ -3252,7 +3250,6 @@ ExecBuildAggTransCall(ExprState *state, AggState *aggstate,
32523250
pertrans->initValueIsNull)
32533251
{
32543252
scratch->opcode=EEOP_AGG_INIT_TRANS;
3255-
scratch->d.agg_init_trans.aggstate=aggstate;
32563253
scratch->d.agg_init_trans.pertrans=pertrans;
32573254
scratch->d.agg_init_trans.setno=setno;
32583255
scratch->d.agg_init_trans.setoff=setoff;
@@ -3269,7 +3266,6 @@ ExecBuildAggTransCall(ExprState *state, AggState *aggstate,
32693266
fcinfo->flinfo->fn_strict)
32703267
{
32713268
scratch->opcode=EEOP_AGG_STRICT_TRANS_CHECK;
3272-
scratch->d.agg_strict_trans_check.aggstate=aggstate;
32733269
scratch->d.agg_strict_trans_check.setno=setno;
32743270
scratch->d.agg_strict_trans_check.setoff=setoff;
32753271
scratch->d.agg_strict_trans_check.transno=transno;
@@ -3294,7 +3290,6 @@ ExecBuildAggTransCall(ExprState *state, AggState *aggstate,
32943290
else
32953291
scratch->opcode=EEOP_AGG_ORDERED_TRANS_TUPLE;
32963292

3297-
scratch->d.agg_trans.aggstate=aggstate;
32983293
scratch->d.agg_trans.pertrans=pertrans;
32993294
scratch->d.agg_trans.setno=setno;
33003295
scratch->d.agg_trans.setoff=setoff;

‎src/backend/executor/execExprInterp.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
15441544
EEO_CASE(EEOP_AGG_DESERIALIZE)
15451545
{
15461546
FunctionCallInfofcinfo=op->d.agg_deserialize.fcinfo_data;
1547-
AggState*aggstate=op->d.agg_deserialize.aggstate;
1547+
AggState*aggstate=castNode(AggState,state->parent);
15481548
MemoryContextoldContext;
15491549

15501550
/*
@@ -1596,10 +1596,9 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
15961596
*/
15971597
EEO_CASE(EEOP_AGG_INIT_TRANS)
15981598
{
1599-
AggState*aggstate;
1599+
AggState*aggstate=castNode(AggState,state->parent);
16001600
AggStatePerGrouppergroup;
16011601

1602-
aggstate=op->d.agg_init_trans.aggstate;
16031602
pergroup=&aggstate->all_pergroups
16041603
[op->d.agg_init_trans.setoff]
16051604
[op->d.agg_init_trans.transno];
@@ -1624,10 +1623,9 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
16241623
/* check that a strict aggregate's input isn't NULL */
16251624
EEO_CASE(EEOP_AGG_STRICT_TRANS_CHECK)
16261625
{
1627-
AggState*aggstate;
1626+
AggState*aggstate=castNode(AggState,state->parent);
16281627
AggStatePerGrouppergroup;
16291628

1630-
aggstate=op->d.agg_strict_trans_check.aggstate;
16311629
pergroup=&aggstate->all_pergroups
16321630
[op->d.agg_strict_trans_check.setoff]
16331631
[op->d.agg_strict_trans_check.transno];
@@ -1645,14 +1643,13 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
16451643
*/
16461644
EEO_CASE(EEOP_AGG_PLAIN_TRANS_BYVAL)
16471645
{
1648-
AggState*aggstate;
1646+
AggState*aggstate=castNode(AggState,state->parent);
16491647
AggStatePerTranspertrans;
16501648
AggStatePerGrouppergroup;
16511649
FunctionCallInfofcinfo;
16521650
MemoryContextoldContext;
16531651
DatumnewVal;
16541652

1655-
aggstate=op->d.agg_trans.aggstate;
16561653
pertrans=op->d.agg_trans.pertrans;
16571654

16581655
pergroup=&aggstate->all_pergroups
@@ -1696,14 +1693,13 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
16961693
*/
16971694
EEO_CASE(EEOP_AGG_PLAIN_TRANS)
16981695
{
1699-
AggState*aggstate;
1696+
AggState*aggstate=castNode(AggState,state->parent);
17001697
AggStatePerTranspertrans;
17011698
AggStatePerGrouppergroup;
17021699
FunctionCallInfofcinfo;
17031700
MemoryContextoldContext;
17041701
DatumnewVal;
17051702

1706-
aggstate=op->d.agg_trans.aggstate;
17071703
pertrans=op->d.agg_trans.pertrans;
17081704

17091705
pergroup=&aggstate->all_pergroups
@@ -3846,8 +3842,9 @@ ExecEvalXmlExpr(ExprState *state, ExprEvalStep *op)
38463842
void
38473843
ExecEvalGroupingFunc(ExprState*state,ExprEvalStep*op)
38483844
{
3845+
AggState*aggstate=castNode(AggState,state->parent);
38493846
intresult=0;
3850-
Bitmapset*grouped_cols=op->d.grouping_func.parent->grouped_cols;
3847+
Bitmapset*grouped_cols=aggstate->grouped_cols;
38513848
ListCell*lc;
38523849

38533850
foreach(lc,op->d.grouping_func.clauses)

‎src/backend/jit/llvm/llvmjit_expr.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ llvm_compile_expr(ExprState *state)
8585
/* state itself */
8686
LLVMValueRefv_state;
8787
LLVMValueRefv_econtext;
88+
LLVMValueRefv_parent;
8889

8990
/* returnvalue */
9091
LLVMValueRefv_isnullp;
@@ -173,6 +174,9 @@ llvm_compile_expr(ExprState *state)
173174
v_tmpisnullp=LLVMBuildStructGEP(b,v_state,
174175
FIELDNO_EXPRSTATE_RESNULL,
175176
"v.state.resnull");
177+
v_parent=l_load_struct_gep(b,v_state,
178+
FIELDNO_EXPRSTATE_PARENT,
179+
"v.state.parent");
176180

177181
/* build global slots */
178182
v_scanslot=l_load_struct_gep(b,v_econtext,
@@ -1989,7 +1993,7 @@ llvm_compile_expr(ExprState *state)
19891993
LLVMValueRefv_tmpcontext;
19901994
LLVMValueRefv_oldcontext;
19911995

1992-
aggstate=op->d.agg_deserialize.aggstate;
1996+
aggstate=castNode(AggState,state->parent);
19931997
fcinfo=op->d.agg_deserialize.fcinfo_data;
19941998

19951999
v_tmpcontext=
@@ -2078,7 +2082,6 @@ llvm_compile_expr(ExprState *state)
20782082

20792083
caseEEOP_AGG_INIT_TRANS:
20802084
{
2081-
AggState*aggstate;
20822085
AggStatePerTranspertrans;
20832086

20842087
LLVMValueRefv_aggstatep;
@@ -2095,11 +2098,10 @@ llvm_compile_expr(ExprState *state)
20952098

20962099
LLVMBasicBlockRefb_init;
20972100

2098-
aggstate=op->d.agg_init_trans.aggstate;
20992101
pertrans=op->d.agg_init_trans.pertrans;
21002102

2101-
v_aggstatep=l_ptr_const(aggstate,
2102-
l_ptr(StructAggState));
2103+
v_aggstatep=
2104+
LLVMBuildBitCast(b,v_parent,l_ptr(StructAggState),"");
21032105
v_pertransp=l_ptr_const(pertrans,
21042106
l_ptr(StructAggStatePerTransData));
21052107

@@ -2176,7 +2178,6 @@ llvm_compile_expr(ExprState *state)
21762178

21772179
caseEEOP_AGG_STRICT_TRANS_CHECK:
21782180
{
2179-
AggState*aggstate;
21802181
LLVMValueRefv_setoff,
21812182
v_transno;
21822183

@@ -2188,8 +2189,8 @@ llvm_compile_expr(ExprState *state)
21882189

21892190
intjumpnull=op->d.agg_strict_trans_check.jumpnull;
21902191

2191-
aggstate=op->d.agg_strict_trans_check.aggstate;
2192-
v_aggstatep=l_ptr_const(aggstate,l_ptr(StructAggState));
2192+
v_aggstatep=
2193+
LLVMBuildBitCast(b,v_parent,l_ptr(StructAggState),"");
21932194

21942195
/*
21952196
* pergroup = &aggstate->all_pergroups
@@ -2256,13 +2257,13 @@ llvm_compile_expr(ExprState *state)
22562257
LLVMValueRefv_tmpcontext;
22572258
LLVMValueRefv_oldcontext;
22582259

2259-
aggstate=op->d.agg_trans.aggstate;
2260+
aggstate=castNode(AggState,state->parent);
22602261
pertrans=op->d.agg_trans.pertrans;
22612262

22622263
fcinfo=pertrans->transfn_fcinfo;
22632264

2264-
v_aggstatep=l_ptr_const(aggstate,
2265-
l_ptr(StructAggState));
2265+
v_aggstatep=
2266+
LLVMBuildBitCast(b,v_parent,l_ptr(StructAggState),"");
22662267
v_pertransp=l_ptr_const(pertrans,
22672268
l_ptr(StructAggStatePerTransData));
22682269

‎src/include/executor/execExpr.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,6 @@ typedef struct ExprEvalStep
569569
/* for EEOP_GROUPING_FUNC */
570570
struct
571571
{
572-
AggState*parent;/* parent Agg */
573572
List*clauses;/* integer list of column numbers */
574573
}grouping_func;
575574

@@ -597,7 +596,6 @@ typedef struct ExprEvalStep
597596
/* for EEOP_AGG_*DESERIALIZE */
598597
struct
599598
{
600-
AggState*aggstate;
601599
FunctionCallInfofcinfo_data;
602600
intjumpnull;
603601
}agg_deserialize;
@@ -625,7 +623,6 @@ typedef struct ExprEvalStep
625623
/* for EEOP_AGG_INIT_TRANS */
626624
struct
627625
{
628-
AggState*aggstate;
629626
AggStatePerTranspertrans;
630627
ExprContext*aggcontext;
631628
intsetno;
@@ -637,7 +634,6 @@ typedef struct ExprEvalStep
637634
/* for EEOP_AGG_STRICT_TRANS_CHECK */
638635
struct
639636
{
640-
AggState*aggstate;
641637
intsetno;
642638
inttransno;
643639
intsetoff;
@@ -647,7 +643,6 @@ typedef struct ExprEvalStep
647643
/* for EEOP_AGG_{PLAIN,ORDERED}_TRANS* */
648644
struct
649645
{
650-
AggState*aggstate;
651646
AggStatePerTranspertrans;
652647
ExprContext*aggcontext;
653648
intsetno;

‎src/include/nodes/execnodes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ typedef struct ExprState
104104
intsteps_len;/* number of steps currently */
105105
intsteps_alloc;/* allocated length of steps array */
106106

107+
#defineFIELDNO_EXPRSTATE_PARENT 11
107108
structPlanState*parent;/* parent PlanState node, if any */
108109
ParamListInfoext_params;/* for compiling PARAM_EXTERN nodes */
109110

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp