mirror of
https://github.com/postgres/postgres.git
synced 2025-06-01 00:01:20 -04:00
expression eval: Don't redundantly keep track of AggState.
It's already tracked via ExprState->parent, so we don't need to also include it in ExprEvalStep. When that code originally was written ExprState->parent didn't exist, but it since has been introduced in 6719b238e8f. Author: Andres Freund Discussion: https://postgr.es/m/20191023163849.sosqbfs5yenocez3@alap3.anarazel.de
This commit is contained in:
parent
1ec7679f1b
commit
1fdb7f9789
@ -810,7 +810,6 @@ ExecInitExprRec(Expr *node, ExprState *state,
|
||||
elog(ERROR, "GroupingFunc found in non-Agg plan node");
|
||||
|
||||
scratch.opcode = EEOP_GROUPING_FUNC;
|
||||
scratch.d.grouping_func.parent = (AggState *) state->parent;
|
||||
|
||||
agg = (Agg *) (state->parent->plan);
|
||||
|
||||
@ -3050,7 +3049,6 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
|
||||
else
|
||||
scratch.opcode = EEOP_AGG_DESERIALIZE;
|
||||
|
||||
scratch.d.agg_deserialize.aggstate = aggstate;
|
||||
scratch.d.agg_deserialize.fcinfo_data = ds_fcinfo;
|
||||
scratch.d.agg_deserialize.jumpnull = -1; /* adjust later */
|
||||
scratch.resvalue = &trans_fcinfo->args[argno + 1].value;
|
||||
@ -3252,7 +3250,6 @@ ExecBuildAggTransCall(ExprState *state, AggState *aggstate,
|
||||
pertrans->initValueIsNull)
|
||||
{
|
||||
scratch->opcode = EEOP_AGG_INIT_TRANS;
|
||||
scratch->d.agg_init_trans.aggstate = aggstate;
|
||||
scratch->d.agg_init_trans.pertrans = pertrans;
|
||||
scratch->d.agg_init_trans.setno = setno;
|
||||
scratch->d.agg_init_trans.setoff = setoff;
|
||||
@ -3269,7 +3266,6 @@ ExecBuildAggTransCall(ExprState *state, AggState *aggstate,
|
||||
fcinfo->flinfo->fn_strict)
|
||||
{
|
||||
scratch->opcode = EEOP_AGG_STRICT_TRANS_CHECK;
|
||||
scratch->d.agg_strict_trans_check.aggstate = aggstate;
|
||||
scratch->d.agg_strict_trans_check.setno = setno;
|
||||
scratch->d.agg_strict_trans_check.setoff = setoff;
|
||||
scratch->d.agg_strict_trans_check.transno = transno;
|
||||
@ -3294,7 +3290,6 @@ ExecBuildAggTransCall(ExprState *state, AggState *aggstate,
|
||||
else
|
||||
scratch->opcode = EEOP_AGG_ORDERED_TRANS_TUPLE;
|
||||
|
||||
scratch->d.agg_trans.aggstate = aggstate;
|
||||
scratch->d.agg_trans.pertrans = pertrans;
|
||||
scratch->d.agg_trans.setno = setno;
|
||||
scratch->d.agg_trans.setoff = setoff;
|
||||
|
@ -1544,7 +1544,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
|
||||
EEO_CASE(EEOP_AGG_DESERIALIZE)
|
||||
{
|
||||
FunctionCallInfo fcinfo = op->d.agg_deserialize.fcinfo_data;
|
||||
AggState *aggstate = op->d.agg_deserialize.aggstate;
|
||||
AggState *aggstate = castNode(AggState, state->parent);
|
||||
MemoryContext oldContext;
|
||||
|
||||
/*
|
||||
@ -1596,10 +1596,9 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
|
||||
*/
|
||||
EEO_CASE(EEOP_AGG_INIT_TRANS)
|
||||
{
|
||||
AggState *aggstate;
|
||||
AggState *aggstate = castNode(AggState, state->parent);
|
||||
AggStatePerGroup pergroup;
|
||||
|
||||
aggstate = op->d.agg_init_trans.aggstate;
|
||||
pergroup = &aggstate->all_pergroups
|
||||
[op->d.agg_init_trans.setoff]
|
||||
[op->d.agg_init_trans.transno];
|
||||
@ -1624,10 +1623,9 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
|
||||
/* check that a strict aggregate's input isn't NULL */
|
||||
EEO_CASE(EEOP_AGG_STRICT_TRANS_CHECK)
|
||||
{
|
||||
AggState *aggstate;
|
||||
AggState *aggstate = castNode(AggState, state->parent);
|
||||
AggStatePerGroup pergroup;
|
||||
|
||||
aggstate = op->d.agg_strict_trans_check.aggstate;
|
||||
pergroup = &aggstate->all_pergroups
|
||||
[op->d.agg_strict_trans_check.setoff]
|
||||
[op->d.agg_strict_trans_check.transno];
|
||||
@ -1645,14 +1643,13 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
|
||||
*/
|
||||
EEO_CASE(EEOP_AGG_PLAIN_TRANS_BYVAL)
|
||||
{
|
||||
AggState *aggstate;
|
||||
AggState *aggstate = castNode(AggState, state->parent);
|
||||
AggStatePerTrans pertrans;
|
||||
AggStatePerGroup pergroup;
|
||||
FunctionCallInfo fcinfo;
|
||||
MemoryContext oldContext;
|
||||
Datum newVal;
|
||||
|
||||
aggstate = op->d.agg_trans.aggstate;
|
||||
pertrans = op->d.agg_trans.pertrans;
|
||||
|
||||
pergroup = &aggstate->all_pergroups
|
||||
@ -1696,14 +1693,13 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
|
||||
*/
|
||||
EEO_CASE(EEOP_AGG_PLAIN_TRANS)
|
||||
{
|
||||
AggState *aggstate;
|
||||
AggState *aggstate = castNode(AggState, state->parent);
|
||||
AggStatePerTrans pertrans;
|
||||
AggStatePerGroup pergroup;
|
||||
FunctionCallInfo fcinfo;
|
||||
MemoryContext oldContext;
|
||||
Datum newVal;
|
||||
|
||||
aggstate = op->d.agg_trans.aggstate;
|
||||
pertrans = op->d.agg_trans.pertrans;
|
||||
|
||||
pergroup = &aggstate->all_pergroups
|
||||
@ -3846,8 +3842,9 @@ ExecEvalXmlExpr(ExprState *state, ExprEvalStep *op)
|
||||
void
|
||||
ExecEvalGroupingFunc(ExprState *state, ExprEvalStep *op)
|
||||
{
|
||||
AggState *aggstate = castNode(AggState, state->parent);
|
||||
int result = 0;
|
||||
Bitmapset *grouped_cols = op->d.grouping_func.parent->grouped_cols;
|
||||
Bitmapset *grouped_cols = aggstate->grouped_cols;
|
||||
ListCell *lc;
|
||||
|
||||
foreach(lc, op->d.grouping_func.clauses)
|
||||
|
@ -85,6 +85,7 @@ llvm_compile_expr(ExprState *state)
|
||||
/* state itself */
|
||||
LLVMValueRef v_state;
|
||||
LLVMValueRef v_econtext;
|
||||
LLVMValueRef v_parent;
|
||||
|
||||
/* returnvalue */
|
||||
LLVMValueRef v_isnullp;
|
||||
@ -173,6 +174,9 @@ llvm_compile_expr(ExprState *state)
|
||||
v_tmpisnullp = LLVMBuildStructGEP(b, v_state,
|
||||
FIELDNO_EXPRSTATE_RESNULL,
|
||||
"v.state.resnull");
|
||||
v_parent = l_load_struct_gep(b, v_state,
|
||||
FIELDNO_EXPRSTATE_PARENT,
|
||||
"v.state.parent");
|
||||
|
||||
/* build global slots */
|
||||
v_scanslot = l_load_struct_gep(b, v_econtext,
|
||||
@ -1989,7 +1993,7 @@ llvm_compile_expr(ExprState *state)
|
||||
LLVMValueRef v_tmpcontext;
|
||||
LLVMValueRef v_oldcontext;
|
||||
|
||||
aggstate = op->d.agg_deserialize.aggstate;
|
||||
aggstate = castNode(AggState, state->parent);
|
||||
fcinfo = op->d.agg_deserialize.fcinfo_data;
|
||||
|
||||
v_tmpcontext =
|
||||
@ -2078,7 +2082,6 @@ llvm_compile_expr(ExprState *state)
|
||||
|
||||
case EEOP_AGG_INIT_TRANS:
|
||||
{
|
||||
AggState *aggstate;
|
||||
AggStatePerTrans pertrans;
|
||||
|
||||
LLVMValueRef v_aggstatep;
|
||||
@ -2095,11 +2098,10 @@ llvm_compile_expr(ExprState *state)
|
||||
|
||||
LLVMBasicBlockRef b_init;
|
||||
|
||||
aggstate = op->d.agg_init_trans.aggstate;
|
||||
pertrans = op->d.agg_init_trans.pertrans;
|
||||
|
||||
v_aggstatep = l_ptr_const(aggstate,
|
||||
l_ptr(StructAggState));
|
||||
v_aggstatep =
|
||||
LLVMBuildBitCast(b, v_parent, l_ptr(StructAggState), "");
|
||||
v_pertransp = l_ptr_const(pertrans,
|
||||
l_ptr(StructAggStatePerTransData));
|
||||
|
||||
@ -2176,7 +2178,6 @@ llvm_compile_expr(ExprState *state)
|
||||
|
||||
case EEOP_AGG_STRICT_TRANS_CHECK:
|
||||
{
|
||||
AggState *aggstate;
|
||||
LLVMValueRef v_setoff,
|
||||
v_transno;
|
||||
|
||||
@ -2188,8 +2189,8 @@ llvm_compile_expr(ExprState *state)
|
||||
|
||||
int jumpnull = op->d.agg_strict_trans_check.jumpnull;
|
||||
|
||||
aggstate = op->d.agg_strict_trans_check.aggstate;
|
||||
v_aggstatep = l_ptr_const(aggstate, l_ptr(StructAggState));
|
||||
v_aggstatep =
|
||||
LLVMBuildBitCast(b, v_parent, l_ptr(StructAggState), "");
|
||||
|
||||
/*
|
||||
* pergroup = &aggstate->all_pergroups
|
||||
@ -2256,13 +2257,13 @@ llvm_compile_expr(ExprState *state)
|
||||
LLVMValueRef v_tmpcontext;
|
||||
LLVMValueRef v_oldcontext;
|
||||
|
||||
aggstate = op->d.agg_trans.aggstate;
|
||||
aggstate = castNode(AggState, state->parent);
|
||||
pertrans = op->d.agg_trans.pertrans;
|
||||
|
||||
fcinfo = pertrans->transfn_fcinfo;
|
||||
|
||||
v_aggstatep = l_ptr_const(aggstate,
|
||||
l_ptr(StructAggState));
|
||||
v_aggstatep =
|
||||
LLVMBuildBitCast(b, v_parent, l_ptr(StructAggState), "");
|
||||
v_pertransp = l_ptr_const(pertrans,
|
||||
l_ptr(StructAggStatePerTransData));
|
||||
|
||||
|
@ -569,7 +569,6 @@ typedef struct ExprEvalStep
|
||||
/* for EEOP_GROUPING_FUNC */
|
||||
struct
|
||||
{
|
||||
AggState *parent; /* parent Agg */
|
||||
List *clauses; /* integer list of column numbers */
|
||||
} grouping_func;
|
||||
|
||||
@ -597,7 +596,6 @@ typedef struct ExprEvalStep
|
||||
/* for EEOP_AGG_*DESERIALIZE */
|
||||
struct
|
||||
{
|
||||
AggState *aggstate;
|
||||
FunctionCallInfo fcinfo_data;
|
||||
int jumpnull;
|
||||
} agg_deserialize;
|
||||
@ -625,7 +623,6 @@ typedef struct ExprEvalStep
|
||||
/* for EEOP_AGG_INIT_TRANS */
|
||||
struct
|
||||
{
|
||||
AggState *aggstate;
|
||||
AggStatePerTrans pertrans;
|
||||
ExprContext *aggcontext;
|
||||
int setno;
|
||||
@ -637,7 +634,6 @@ typedef struct ExprEvalStep
|
||||
/* for EEOP_AGG_STRICT_TRANS_CHECK */
|
||||
struct
|
||||
{
|
||||
AggState *aggstate;
|
||||
int setno;
|
||||
int transno;
|
||||
int setoff;
|
||||
@ -647,7 +643,6 @@ typedef struct ExprEvalStep
|
||||
/* for EEOP_AGG_{PLAIN,ORDERED}_TRANS* */
|
||||
struct
|
||||
{
|
||||
AggState *aggstate;
|
||||
AggStatePerTrans pertrans;
|
||||
ExprContext *aggcontext;
|
||||
int setno;
|
||||
|
@ -104,6 +104,7 @@ typedef struct ExprState
|
||||
int steps_len; /* number of steps currently */
|
||||
int steps_alloc; /* allocated length of steps array */
|
||||
|
||||
#define FIELDNO_EXPRSTATE_PARENT 11
|
||||
struct PlanState *parent; /* parent PlanState node, if any */
|
||||
ParamListInfo ext_params; /* for compiling PARAM_EXTERN nodes */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user