mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Improve handling of group-column indexes in GroupingSetsPath.
Instead of having planner.c compute a groupColIdx array and store it in GroupingSetsPaths, make create_groupingsets_plan() find the grouping columns by searching in the child plan node's tlist. Although that's probably a bit slower for create_groupingsets_plan(), it's more like the way every other plan node type does this, and it provides positive confirmation that we know which child output columns we're supposed to be grouping on. (Indeed, looking at this now, I'm not at all sure that it wasn't broken before, because create_groupingsets_plan() isn't demanding an exact tlist match from its child node.) Also, this allows substantial simplification in planner.c, because it no longer needs to compute the groupColIdx array at all; no other cases were using it. I'd intended to put off this refactoring until later (like 9.7), but in view of the likely bug fix and the need to rationalize planner.c's tlist handling so we can do something sane with Konstantin Knizhnik's function-evaluation-postponement patch, I think it can't wait.
This commit is contained in:
@ -2438,13 +2438,12 @@ create_agg_path(PlannerInfo *root,
|
||||
*
|
||||
* GroupingSetsPath represents sorted grouping with one or more grouping sets.
|
||||
* The input path's result must be sorted to match the last entry in
|
||||
* rollup_groupclauses, and groupColIdx[] identifies its sort columns.
|
||||
* rollup_groupclauses.
|
||||
*
|
||||
* 'rel' is the parent relation associated with the result
|
||||
* 'subpath' is the path representing the source of data
|
||||
* 'target' is the PathTarget to be computed
|
||||
* 'having_qual' is the HAVING quals if any
|
||||
* 'groupColIdx' is an array of indexes of grouping columns in the source data
|
||||
* 'rollup_lists' is a list of grouping sets
|
||||
* 'rollup_groupclauses' is a list of grouping clauses for grouping sets
|
||||
* 'agg_costs' contains cost info about the aggregate functions to be computed
|
||||
@ -2456,7 +2455,6 @@ create_groupingsets_path(PlannerInfo *root,
|
||||
Path *subpath,
|
||||
PathTarget *target,
|
||||
List *having_qual,
|
||||
AttrNumber *groupColIdx,
|
||||
List *rollup_lists,
|
||||
List *rollup_groupclauses,
|
||||
const AggClauseCosts *agg_costs,
|
||||
@ -2487,7 +2485,6 @@ create_groupingsets_path(PlannerInfo *root,
|
||||
else
|
||||
pathnode->path.pathkeys = NIL;
|
||||
|
||||
pathnode->groupColIdx = groupColIdx;
|
||||
pathnode->rollup_groupclauses = rollup_groupclauses;
|
||||
pathnode->rollup_lists = rollup_lists;
|
||||
pathnode->qual = having_qual;
|
||||
|
Reference in New Issue
Block a user