From df0f50a9bdf32def4a8768ad03e75e6a6b42b249 Mon Sep 17 00:00:00 2001 From: Tomas Vondra Date: Thu, 19 Mar 2020 02:54:39 +0100 Subject: [PATCH 5/7] fix --- .../postgres_fdw/expected/postgres_fdw.out | 4 ++-- src/backend/executor/execExpr.c | 5 +++-- src/backend/executor/nodeAgg.c | 20 +++++++++---------- src/backend/optimizer/util/pathnode.c | 4 ++-- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/contrib/postgres_fdw/expected/postgres_fdw.out b/contrib/postgres_fdw/expected/postgres_fdw.out index 62c2697920..fc0ed2f4d5 100644 --- a/contrib/postgres_fdw/expected/postgres_fdw.out +++ b/contrib/postgres_fdw/expected/postgres_fdw.out @@ -3448,8 +3448,8 @@ select c2, sum(c1) from ft1 where c2 < 3 group by rollup(c2) order by 1 nulls la Sort Key: ft1.c2 -> MixedAggregate Output: c2, sum(c1) - Hash Key: ft1.c2 Group Key: () + Hash Key: ft1.c2 -> Foreign Scan on public.ft1 Output: c2, c1 Remote SQL: SELECT "C 1", c2 FROM "S 1"."T 1" WHERE ((c2 < 3)) @@ -3473,8 +3473,8 @@ select c2, sum(c1) from ft1 where c2 < 3 group by cube(c2) order by 1 nulls last Sort Key: ft1.c2 -> MixedAggregate Output: c2, sum(c1) - Hash Key: ft1.c2 Group Key: () + Hash Key: ft1.c2 -> Foreign Scan on public.ft1 Output: c2, c1 Remote SQL: SELECT "C 1", c2 FROM "S 1"."T 1" WHERE ((c2 < 3)) diff --git a/src/backend/executor/execExpr.c b/src/backend/executor/execExpr.c index 07789501f7..669843faf5 100644 --- a/src/backend/executor/execExpr.c +++ b/src/backend/executor/execExpr.c @@ -2937,7 +2937,7 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase, bool nullcheck) PlanState *parent = &aggstate->ss.ps; ExprEvalStep scratch = {0}; bool isCombine = DO_AGGSPLIT_COMBINE(aggstate->aggsplit); - ListCell *lc; + ListCell *lc; LastAttnumInfo deform = {0, 0, 0}; state->expr = (Expr *) aggstate; @@ -2978,6 +2978,7 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase, bool nullcheck) NullableDatum *strictargs = NULL; bool *strictnulls = NULL; int argno; + int setno; ListCell *bail; /* @@ -3155,7 +3156,7 @@ ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase, bool nullcheck) * grouping set). Do so for both sort and hash based computations, as * applicable. */ - for (int setno = 0; setno < phase->numsets; setno++) + for (setno = 0; setno < phase->numsets; setno++) { ExecBuildAggTransCall(state, aggstate, &scratch, trans_fcinfo, pertrans, transno, setno, phase, nullcheck); diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index 20c5eb98b3..38d0bd5895 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -333,7 +333,7 @@ initialize_phase(AggState *aggstate, int newphase) AggStatePerPhaseSort persort; Assert(newphase == 0 || newphase == aggstate->current_phase + 1); - + /* Don't use aggstate->phase here, it might not be initialized yet*/ current_phase = aggstate->phases[aggstate->current_phase]; @@ -1516,7 +1516,7 @@ hash_agg_entry_size(int numAggs, Size tupleWidth, Size transitionSpace) * When called, CurrentMemoryContext should be the per-query context. The * already-calculated hash value for the tuple must be specified. */ -static void +static void lookup_hash_entry(AggState *aggstate, AggStatePerPhaseHash perhash, uint32 hash) { TupleTableSlot *hashslot = perhash->hashslot; @@ -1724,7 +1724,7 @@ agg_retrieve_direct(AggState *aggstate) numGroupingSets = aggstate->phase->numsets; node = aggstate->phase->aggnode; numReset = numGroupingSets; - pergroups = aggstate->phase->pergroups; + pergroups = aggstate->phase->pergroups; } else { @@ -2123,7 +2123,7 @@ agg_retrieve_hash_table(AggState *aggstate) */ select_current_set(aggstate, 0, true); initialize_phase(aggstate, aggstate->current_phase + 1); - perhash = (AggStatePerPhaseHash) aggstate->phase; + perhash = (AggStatePerPhaseHash) aggstate->phase; ResetTupleHashIterator(perhash->hashtable, &perhash->hashiter); continue; @@ -2269,7 +2269,7 @@ ExecInitAgg(Agg *node, EState *estate, int eflags) aggstate->maxsets = numGroupingSets; aggstate->numphases = 1 + list_length(node->chain); - + /* * The first phase is not sorted, agg need to do its own sort. See * agg_sort_input(), this can only happen in groupingsets case. @@ -2390,7 +2390,7 @@ ExecInitAgg(Agg *node, EState *estate, int eflags) numaggs = aggstate->numaggs; Assert(numaggs == list_length(aggstate->aggs)); - /* + /* * For each phase, prepare grouping set data and fmgr lookup data for * compare functions. Accumulate all_grouped_cols in passing. */ @@ -2430,7 +2430,7 @@ ExecInitAgg(Agg *node, EState *estate, int eflags) all_grouped_cols = bms_add_members(all_grouped_cols, cols); - /* + /* * Initialize pergroup state. For AGG_HASHED, all groups do transition * on the fly, all pergroup states are kept in hashtable, everytime * a tuple is processed, lookup_hash_entry() choose one group and @@ -2499,7 +2499,7 @@ ExecInitAgg(Agg *node, EState *estate, int eflags) phasedata->grouped_cols = NULL; } - /* + /* * Initialize pergroup states for AGG_SORTED/AGG_PLAIN/AGG_MIXED * phases, each set only have one group on the fly, all groups in * a set can reuse a pergroup state. Unlike AGG_HASHED, we @@ -3610,8 +3610,8 @@ ExecReScanAgg(AggState *node) sizeof(AggStatePerGroupData) * node->numaggs); } - /* - * the agg did its own first sort using tuplesort and the first + /* + * The agg did its own first sort using tuplesort and the first * tuplesort is kept (see initialize_phase), if the subplan does * not have any parameter changes, and none of our own parameter * changes affect input expressions of the aggregated functions, diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index 2dfa3fa17e..ff8f676dfb 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -2983,7 +2983,7 @@ create_agg_path(PlannerInfo *root, * 'rollups' is a list of RollupData nodes * 'agg_costs' contains cost info about the aggregate functions to be computed * 'numGroups' is the estimated total number of groups - * 'is_sorted' is the input sorted in the group cols of first rollup + * 'is_sorted' is the input sorted in the group cols of first rollup */ GroupingSetsPath * create_groupingsets_path(PlannerInfo *root, @@ -3098,7 +3098,7 @@ create_groupingsets_path(PlannerInfo *root, AggStrategy rollup_strategy; Path sort_path; /* dummy for result of cost_sort */ Path agg_path; /* dummy for result of cost_agg */ - + sort_path.startup_cost = 0; sort_path.total_cost = 0; sort_path.rows = subpath->rows; -- 2.21.1