mirror of
https://github.com/postgres/postgres.git
synced 2025-07-08 11:42:09 +03:00
expression eval, jit: Minor code cleanups.
This mostly consists of using C99 style for loops, moving variables into narrower scopes, and a smattering of other minor improvements. Done separately to make it easier to review patches with actual functional changes. Author: Andres Freund Discussion: https://postgr.es/m/20191023163849.sosqbfs5yenocez3@alap3.anarazel.de
This commit is contained in:
@ -2779,12 +2779,7 @@ static void
|
||||
ExecInitCoerceToDomain(ExprEvalStep *scratch, CoerceToDomain *ctest,
|
||||
ExprState *state, Datum *resv, bool *resnull)
|
||||
{
|
||||
ExprEvalStep scratch2 = {0};
|
||||
DomainConstraintRef *constraint_ref;
|
||||
Datum *domainval = NULL;
|
||||
bool *domainnull = NULL;
|
||||
Datum *save_innermost_domainval;
|
||||
bool *save_innermost_domainnull;
|
||||
ListCell *l;
|
||||
|
||||
scratch->d.domaincheck.resulttype = ctest->resulttype;
|
||||
@ -2831,6 +2826,10 @@ ExecInitCoerceToDomain(ExprEvalStep *scratch, CoerceToDomain *ctest,
|
||||
foreach(l, constraint_ref->constraints)
|
||||
{
|
||||
DomainConstraintState *con = (DomainConstraintState *) lfirst(l);
|
||||
Datum *domainval = NULL;
|
||||
bool *domainnull = NULL;
|
||||
Datum *save_innermost_domainval;
|
||||
bool *save_innermost_domainnull;
|
||||
|
||||
scratch->d.domaincheck.constraintname = con->name;
|
||||
|
||||
@ -2862,6 +2861,8 @@ ExecInitCoerceToDomain(ExprEvalStep *scratch, CoerceToDomain *ctest,
|
||||
*/
|
||||
if (get_typlen(ctest->resulttype) == -1)
|
||||
{
|
||||
ExprEvalStep scratch2 = {0};
|
||||
|
||||
/* Yes, so make output workspace for MAKE_READONLY */
|
||||
domainval = (Datum *) palloc(sizeof(Datum));
|
||||
domainnull = (bool *) palloc(sizeof(bool));
|
||||
@ -2932,8 +2933,6 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
|
||||
ExprState *state = makeNode(ExprState);
|
||||
PlanState *parent = &aggstate->ss.ps;
|
||||
ExprEvalStep scratch = {0};
|
||||
int transno = 0;
|
||||
int setoff = 0;
|
||||
bool isCombine = DO_AGGSPLIT_COMBINE(aggstate->aggsplit);
|
||||
LastAttnumInfo deform = {0, 0, 0};
|
||||
|
||||
@ -2947,7 +2946,7 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
|
||||
* First figure out which slots, and how many columns from each, we're
|
||||
* going to need.
|
||||
*/
|
||||
for (transno = 0; transno < aggstate->numtrans; transno++)
|
||||
for (int transno = 0; transno < aggstate->numtrans; transno++)
|
||||
{
|
||||
AggStatePerTrans pertrans = &aggstate->pertrans[transno];
|
||||
|
||||
@ -2967,17 +2966,15 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
|
||||
/*
|
||||
* Emit instructions for each transition value / grouping set combination.
|
||||
*/
|
||||
for (transno = 0; transno < aggstate->numtrans; transno++)
|
||||
for (int transno = 0; transno < aggstate->numtrans; transno++)
|
||||
{
|
||||
AggStatePerTrans pertrans = &aggstate->pertrans[transno];
|
||||
int argno;
|
||||
int setno;
|
||||
FunctionCallInfo trans_fcinfo = pertrans->transfn_fcinfo;
|
||||
ListCell *arg;
|
||||
ListCell *bail;
|
||||
List *adjust_bailout = NIL;
|
||||
NullableDatum *strictargs = NULL;
|
||||
bool *strictnulls = NULL;
|
||||
int argno;
|
||||
ListCell *bail;
|
||||
|
||||
/*
|
||||
* If filter present, emit. Do so before evaluating the input, to
|
||||
@ -3071,6 +3068,8 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
|
||||
}
|
||||
else if (pertrans->numSortCols == 0)
|
||||
{
|
||||
ListCell *arg;
|
||||
|
||||
/*
|
||||
* Normal transition function without ORDER BY / DISTINCT.
|
||||
*/
|
||||
@ -3113,6 +3112,7 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
|
||||
*/
|
||||
Datum *values = pertrans->sortslot->tts_values;
|
||||
bool *nulls = pertrans->sortslot->tts_isnull;
|
||||
ListCell *arg;
|
||||
|
||||
strictnulls = nulls;
|
||||
|
||||
@ -3152,12 +3152,12 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
|
||||
* grouping set). Do so for both sort and hash based computations, as
|
||||
* applicable.
|
||||
*/
|
||||
setoff = 0;
|
||||
if (doSort)
|
||||
{
|
||||
int processGroupingSets = Max(phase->numsets, 1);
|
||||
int setoff = 0;
|
||||
|
||||
for (setno = 0; setno < processGroupingSets; setno++)
|
||||
for (int setno = 0; setno < processGroupingSets; setno++)
|
||||
{
|
||||
ExecBuildAggTransCall(state, aggstate, &scratch, trans_fcinfo,
|
||||
pertrans, transno, setno, setoff, false);
|
||||
@ -3168,6 +3168,7 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
|
||||
if (doHash)
|
||||
{
|
||||
int numHashes = aggstate->num_hashes;
|
||||
int setoff;
|
||||
|
||||
/* in MIXED mode, there'll be preceding transition values */
|
||||
if (aggstate->aggstrategy != AGG_HASHED)
|
||||
@ -3175,7 +3176,7 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
|
||||
else
|
||||
setoff = 0;
|
||||
|
||||
for (setno = 0; setno < numHashes; setno++)
|
||||
for (int setno = 0; setno < numHashes; setno++)
|
||||
{
|
||||
ExecBuildAggTransCall(state, aggstate, &scratch, trans_fcinfo,
|
||||
pertrans, transno, setno, setoff, true);
|
||||
@ -3204,6 +3205,8 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase,
|
||||
Assert(as->d.agg_deserialize.jumpnull == -1);
|
||||
as->d.agg_deserialize.jumpnull = state->steps_len;
|
||||
}
|
||||
else
|
||||
Assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3338,7 +3341,6 @@ ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc,
|
||||
{
|
||||
ExprState *state = makeNode(ExprState);
|
||||
ExprEvalStep scratch = {0};
|
||||
int natt;
|
||||
int maxatt = -1;
|
||||
List *adjust_jumps = NIL;
|
||||
ListCell *lc;
|
||||
@ -3358,7 +3360,7 @@ ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc,
|
||||
scratch.resnull = &state->resnull;
|
||||
|
||||
/* compute max needed attribute */
|
||||
for (natt = 0; natt < numCols; natt++)
|
||||
for (int natt = 0; natt < numCols; natt++)
|
||||
{
|
||||
int attno = keyColIdx[natt];
|
||||
|
||||
@ -3388,7 +3390,7 @@ ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc,
|
||||
* Start comparing at the last field (least significant sort key). That's
|
||||
* the most likely to be different if we are dealing with sorted input.
|
||||
*/
|
||||
for (natt = numCols; --natt >= 0;)
|
||||
for (int natt = numCols; --natt >= 0;)
|
||||
{
|
||||
int attno = keyColIdx[natt];
|
||||
Form_pg_attribute latt = TupleDescAttr(ldesc, attno - 1);
|
||||
|
Reference in New Issue
Block a user