diff options
Diffstat (limited to 'src/backend/executor/execExpr.c')
-rw-r--r-- | src/backend/executor/execExpr.c | 83 |
1 files changed, 45 insertions, 38 deletions
diff --git a/src/backend/executor/execExpr.c b/src/backend/executor/execExpr.c index 4047d24b03e..2e061a5ee36 100644 --- a/src/backend/executor/execExpr.c +++ b/src/backend/executor/execExpr.c @@ -966,7 +966,7 @@ ExecInitExprRec(Expr *node, ExprState *state, /* Set up the primary fmgr lookup information */ finfo = palloc0(sizeof(FmgrInfo)); - fcinfo = palloc0(sizeof(FunctionCallInfoData)); + fcinfo = palloc0(SizeForFunctionCallInfo(2)); fmgr_info(opexpr->opfuncid, finfo); fmgr_info_set_expr((Node *) node, finfo); InitFunctionCallInfoData(*fcinfo, finfo, 2, @@ -974,7 +974,7 @@ ExecInitExprRec(Expr *node, ExprState *state, /* Evaluate scalar directly into left function argument */ ExecInitExprRec(scalararg, state, - &fcinfo->arg[0], &fcinfo->argnull[0]); + &fcinfo->args[0].value, &fcinfo->args[0].isnull); /* * Evaluate array argument into our return value. There's no @@ -1263,7 +1263,7 @@ ExecInitExprRec(Expr *node, ExprState *state, /* lookup the source type's output function */ scratch.d.iocoerce.finfo_out = palloc0(sizeof(FmgrInfo)); - scratch.d.iocoerce.fcinfo_data_out = palloc0(sizeof(FunctionCallInfoData)); + scratch.d.iocoerce.fcinfo_data_out = palloc0(SizeForFunctionCallInfo(1)); getTypeOutputInfo(exprType((Node *) iocoerce->arg), &iofunc, &typisvarlena); @@ -1275,7 +1275,7 @@ ExecInitExprRec(Expr *node, ExprState *state, /* lookup the result type's input function */ scratch.d.iocoerce.finfo_in = palloc0(sizeof(FmgrInfo)); - scratch.d.iocoerce.fcinfo_data_in = palloc0(sizeof(FunctionCallInfoData)); + scratch.d.iocoerce.fcinfo_data_in = palloc0(SizeForFunctionCallInfo(3)); getTypeInputInfo(iocoerce->resulttype, &iofunc, &typioparam); @@ -1290,10 +1290,10 @@ ExecInitExprRec(Expr *node, ExprState *state, * function, since they're constants. */ fcinfo_in = scratch.d.iocoerce.fcinfo_data_in; - fcinfo_in->arg[1] = ObjectIdGetDatum(typioparam); - fcinfo_in->argnull[1] = false; - fcinfo_in->arg[2] = Int32GetDatum(-1); - fcinfo_in->argnull[2] = false; + fcinfo_in->args[1].value = ObjectIdGetDatum(typioparam); + fcinfo_in->args[1].isnull = false; + fcinfo_in->args[2].value = Int32GetDatum(-1); + fcinfo_in->args[2].isnull = false; ExprEvalPushStep(state, &scratch); break; @@ -1735,7 +1735,7 @@ ExecInitExprRec(Expr *node, ExprState *state, /* Set up the primary fmgr lookup information */ finfo = palloc0(sizeof(FmgrInfo)); - fcinfo = palloc0(sizeof(FunctionCallInfoData)); + fcinfo = palloc0(SizeForFunctionCallInfo(2)); fmgr_info(proc, finfo); fmgr_info_set_expr((Node *) node, finfo); InitFunctionCallInfoData(*fcinfo, finfo, 2, @@ -1750,9 +1750,9 @@ ExecInitExprRec(Expr *node, ExprState *state, /* evaluate left and right args directly into fcinfo */ ExecInitExprRec(left_expr, state, - &fcinfo->arg[0], &fcinfo->argnull[0]); + &fcinfo->args[0].value, &fcinfo->args[0].isnull); ExecInitExprRec(right_expr, state, - &fcinfo->arg[1], &fcinfo->argnull[1]); + &fcinfo->args[1].value, &fcinfo->args[1].isnull); scratch.opcode = EEOP_ROWCOMPARE_STEP; scratch.d.rowcompare_step.finfo = finfo; @@ -1878,7 +1878,7 @@ ExecInitExprRec(Expr *node, ExprState *state, /* Perform function lookup */ finfo = palloc0(sizeof(FmgrInfo)); - fcinfo = palloc0(sizeof(FunctionCallInfoData)); + fcinfo = palloc0(SizeForFunctionCallInfo(2)); fmgr_info(typentry->cmp_proc, finfo); fmgr_info_set_expr((Node *) node, finfo); InitFunctionCallInfoData(*fcinfo, finfo, 2, @@ -2187,7 +2187,7 @@ ExecInitFunc(ExprEvalStep *scratch, Expr *node, List *args, Oid funcid, /* Allocate function lookup data and parameter workspace for this call */ scratch->d.func.finfo = palloc0(sizeof(FmgrInfo)); - scratch->d.func.fcinfo_data = palloc0(sizeof(FunctionCallInfoData)); + scratch->d.func.fcinfo_data = palloc0(SizeForFunctionCallInfo(nargs)); flinfo = scratch->d.func.finfo; fcinfo = scratch->d.func.fcinfo_data; @@ -2226,13 +2226,14 @@ ExecInitFunc(ExprEvalStep *scratch, Expr *node, List *args, Oid funcid, */ Const *con = (Const *) arg; - fcinfo->arg[argno] = con->constvalue; - fcinfo->argnull[argno] = con->constisnull; + fcinfo->args[argno].value = con->constvalue; + fcinfo->args[argno].isnull = con->constisnull; } else { ExecInitExprRec(arg, state, - &fcinfo->arg[argno], &fcinfo->argnull[argno]); + &fcinfo->args[argno].value, + &fcinfo->args[argno].isnull); } argno++; } @@ -2961,10 +2962,11 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase, AggStatePerTrans pertrans = &aggstate->pertrans[transno]; int argno; int setno; - FunctionCallInfo trans_fcinfo = &pertrans->transfn_fcinfo; + FunctionCallInfo trans_fcinfo = pertrans->transfn_fcinfo; ListCell *arg; ListCell *bail; List *adjust_bailout = NIL; + NullableDatum *strictargs = NULL; bool *strictnulls = NULL; /* @@ -3002,7 +3004,7 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase, Assert(pertrans->numSortCols == 0); Assert(list_length(pertrans->aggref->args) == 1); - strictnulls = trans_fcinfo->argnull + 1; + strictargs = trans_fcinfo->args + 1; source_tle = (TargetEntry *) linitial(pertrans->aggref->args); /* @@ -3016,21 +3018,21 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase, * value */ ExecInitExprRec(source_tle->expr, state, - &trans_fcinfo->arg[argno + 1], - &trans_fcinfo->argnull[argno + 1]); + &trans_fcinfo->args[argno + 1].value, + &trans_fcinfo->args[argno + 1].isnull); } else { - FunctionCallInfo ds_fcinfo = &pertrans->deserialfn_fcinfo; + FunctionCallInfo ds_fcinfo = pertrans->deserialfn_fcinfo; /* evaluate argument */ ExecInitExprRec(source_tle->expr, state, - &ds_fcinfo->arg[0], - &ds_fcinfo->argnull[0]); + &ds_fcinfo->args[0].value, + &ds_fcinfo->args[0].isnull); /* Dummy second argument for type-safety reasons */ - ds_fcinfo->arg[1] = PointerGetDatum(NULL); - ds_fcinfo->argnull[1] = false; + ds_fcinfo->args[1].value = PointerGetDatum(NULL); + ds_fcinfo->args[1].isnull = false; /* * Don't call a strict deserialization function with NULL @@ -3044,8 +3046,8 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase, 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->arg[argno + 1]; - scratch.resnull = &trans_fcinfo->argnull[argno + 1]; + scratch.resvalue = &trans_fcinfo->args[argno + 1].value; + scratch.resnull = &trans_fcinfo->args[argno + 1].isnull; ExprEvalPushStep(state, &scratch); adjust_bailout = lappend_int(adjust_bailout, @@ -3062,7 +3064,7 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase, /* * Normal transition function without ORDER BY / DISTINCT. */ - strictnulls = trans_fcinfo->argnull + 1; + strictargs = trans_fcinfo->args + 1; foreach(arg, pertrans->aggref->args) { @@ -3073,8 +3075,8 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase, * value */ ExecInitExprRec(source_tle->expr, state, - &trans_fcinfo->arg[argno + 1], - &trans_fcinfo->argnull[argno + 1]); + &trans_fcinfo->args[argno + 1].value, + &trans_fcinfo->args[argno + 1].isnull); argno++; } } @@ -3122,8 +3124,12 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase, */ if (trans_fcinfo->flinfo->fn_strict && pertrans->numTransInputs > 0) { - scratch.opcode = EEOP_AGG_STRICT_INPUT_CHECK; + if (strictnulls) + scratch.opcode = EEOP_AGG_STRICT_INPUT_CHECK_NULLS; + else + scratch.opcode = EEOP_AGG_STRICT_INPUT_CHECK_ARGS; scratch.d.agg_strict_input_check.nulls = strictnulls; + scratch.d.agg_strict_input_check.args = strictargs; scratch.d.agg_strict_input_check.jumpnull = -1; /* adjust later */ scratch.d.agg_strict_input_check.nargs = pertrans->numTransInputs; ExprEvalPushStep(state, &scratch); @@ -3177,7 +3183,8 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase, Assert(as->d.jump.jumpdone == -1); as->d.jump.jumpdone = state->steps_len; } - else if (as->opcode == EEOP_AGG_STRICT_INPUT_CHECK) + else if (as->opcode == EEOP_AGG_STRICT_INPUT_CHECK_ARGS || + as->opcode == EEOP_AGG_STRICT_INPUT_CHECK_NULLS) { Assert(as->d.agg_strict_input_check.jumpnull == -1); as->d.agg_strict_input_check.jumpnull = state->steps_len; @@ -3312,7 +3319,7 @@ ExecBuildAggTransCall(ExprState *state, AggState *aggstate, */ ExprState * ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc, - const TupleTableSlotOps *lops, const TupleTableSlotOps *rops, + const TupleTableSlotOps * lops, const TupleTableSlotOps * rops, int numCols, const AttrNumber *keyColIdx, const Oid *eqfunctions, @@ -3389,7 +3396,7 @@ ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc, /* Set up the primary fmgr lookup information */ finfo = palloc0(sizeof(FmgrInfo)); - fcinfo = palloc0(sizeof(FunctionCallInfoData)); + fcinfo = palloc0(SizeForFunctionCallInfo(2)); fmgr_info(foid, finfo); fmgr_info_set_expr(NULL, finfo); InitFunctionCallInfoData(*fcinfo, finfo, 2, @@ -3399,16 +3406,16 @@ ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc, scratch.opcode = EEOP_INNER_VAR; scratch.d.var.attnum = attno - 1; scratch.d.var.vartype = latt->atttypid; - scratch.resvalue = &fcinfo->arg[0]; - scratch.resnull = &fcinfo->argnull[0]; + scratch.resvalue = &fcinfo->args[0].value; + scratch.resnull = &fcinfo->args[0].isnull; ExprEvalPushStep(state, &scratch); /* right arg */ scratch.opcode = EEOP_OUTER_VAR; scratch.d.var.attnum = attno - 1; scratch.d.var.vartype = ratt->atttypid; - scratch.resvalue = &fcinfo->arg[1]; - scratch.resnull = &fcinfo->argnull[1]; + scratch.resvalue = &fcinfo->args[1].value; + scratch.resnull = &fcinfo->args[1].isnull; ExprEvalPushStep(state, &scratch); /* evaluate distinctness */ |