Commit 94150513 authored by Robert Haas's avatar Robert Haas

Don't pass the grouping target around unnecessarily.

Since commit 4f15e5d0 made grouped_rel
set reltarget, a variety of other functions can just get it from
grouped_rel instead of having to pass it around explicitly.  Simplify
accordingly.

Patch by me, reviewed by Ashutosh Bapat.

Discussion: http://postgr.es/m/CA+TgmoZ+ZJTVad-=vEq393N99KTooxv9k7M+z73qnTAqkb49BQ@mail.gmail.com
parent b6cbe9ea
...@@ -163,10 +163,10 @@ static RelOptInfo *create_grouping_paths(PlannerInfo *root, ...@@ -163,10 +163,10 @@ static RelOptInfo *create_grouping_paths(PlannerInfo *root,
static bool is_degenerate_grouping(PlannerInfo *root); static bool is_degenerate_grouping(PlannerInfo *root);
static void create_degenerate_grouping_paths(PlannerInfo *root, static void create_degenerate_grouping_paths(PlannerInfo *root,
RelOptInfo *input_rel, RelOptInfo *input_rel,
PathTarget *target, RelOptInfo *grouped_rel); RelOptInfo *grouped_rel);
static void create_ordinary_grouping_paths(PlannerInfo *root, static void create_ordinary_grouping_paths(PlannerInfo *root,
RelOptInfo *input_rel, RelOptInfo *input_rel,
PathTarget *target, RelOptInfo *grouped_rel, RelOptInfo *grouped_rel,
const AggClauseCosts *agg_costs, const AggClauseCosts *agg_costs,
grouping_sets_data *gd, int flags); grouping_sets_data *gd, int flags);
static void consider_groupingsets_paths(PlannerInfo *root, static void consider_groupingsets_paths(PlannerInfo *root,
...@@ -174,7 +174,6 @@ static void consider_groupingsets_paths(PlannerInfo *root, ...@@ -174,7 +174,6 @@ static void consider_groupingsets_paths(PlannerInfo *root,
Path *path, Path *path,
bool is_sorted, bool is_sorted,
bool can_hash, bool can_hash,
PathTarget *target,
grouping_sets_data *gd, grouping_sets_data *gd,
const AggClauseCosts *agg_costs, const AggClauseCosts *agg_costs,
double dNumGroups); double dNumGroups);
...@@ -220,7 +219,6 @@ static void adjust_paths_for_srfs(PlannerInfo *root, RelOptInfo *rel, ...@@ -220,7 +219,6 @@ static void adjust_paths_for_srfs(PlannerInfo *root, RelOptInfo *rel,
List *targets, List *targets_contain_srfs); List *targets, List *targets_contain_srfs);
static void add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel, static void add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
RelOptInfo *grouped_rel, RelOptInfo *grouped_rel,
PathTarget *target,
RelOptInfo *partially_grouped_rel, RelOptInfo *partially_grouped_rel,
const AggClauseCosts *agg_costs, const AggClauseCosts *agg_costs,
const AggClauseCosts *agg_final_costs, const AggClauseCosts *agg_final_costs,
...@@ -3737,7 +3735,7 @@ create_grouping_paths(PlannerInfo *root, ...@@ -3737,7 +3735,7 @@ create_grouping_paths(PlannerInfo *root,
* grouping, as appropriate. * grouping, as appropriate.
*/ */
if (is_degenerate_grouping(root)) if (is_degenerate_grouping(root))
create_degenerate_grouping_paths(root, input_rel, target, grouped_rel); create_degenerate_grouping_paths(root, input_rel, grouped_rel);
else else
{ {
int flags = 0; int flags = 0;
...@@ -3788,7 +3786,7 @@ create_grouping_paths(PlannerInfo *root, ...@@ -3788,7 +3786,7 @@ create_grouping_paths(PlannerInfo *root,
if (can_partial_agg(root, agg_costs)) if (can_partial_agg(root, agg_costs))
flags |= GROUPING_CAN_PARTIAL_AGG; flags |= GROUPING_CAN_PARTIAL_AGG;
create_ordinary_grouping_paths(root, input_rel, target, grouped_rel, create_ordinary_grouping_paths(root, input_rel, grouped_rel,
agg_costs, gd, flags); agg_costs, gd, flags);
} }
...@@ -3826,7 +3824,7 @@ is_degenerate_grouping(PlannerInfo *root) ...@@ -3826,7 +3824,7 @@ is_degenerate_grouping(PlannerInfo *root)
*/ */
static void static void
create_degenerate_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel, create_degenerate_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
PathTarget *target, RelOptInfo *grouped_rel) RelOptInfo *grouped_rel)
{ {
Query *parse = root->parse; Query *parse = root->parse;
int nrows; int nrows;
...@@ -3848,7 +3846,7 @@ create_degenerate_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel, ...@@ -3848,7 +3846,7 @@ create_degenerate_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
{ {
path = (Path *) path = (Path *)
create_result_path(root, grouped_rel, create_result_path(root, grouped_rel,
target, grouped_rel->reltarget,
(List *) parse->havingQual); (List *) parse->havingQual);
paths = lappend(paths, path); paths = lappend(paths, path);
} }
...@@ -3861,14 +3859,13 @@ create_degenerate_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel, ...@@ -3861,14 +3859,13 @@ create_degenerate_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
false, false,
NIL, NIL,
-1); -1);
path->pathtarget = target;
} }
else else
{ {
/* No grouping sets, or just one, so one output row */ /* No grouping sets, or just one, so one output row */
path = (Path *) path = (Path *)
create_result_path(root, grouped_rel, create_result_path(root, grouped_rel,
target, grouped_rel->reltarget,
(List *) parse->havingQual); (List *) parse->havingQual);
} }
...@@ -3887,7 +3884,7 @@ create_degenerate_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel, ...@@ -3887,7 +3884,7 @@ create_degenerate_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
*/ */
static void static void
create_ordinary_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel, create_ordinary_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
PathTarget *target, RelOptInfo *grouped_rel, RelOptInfo *grouped_rel,
const AggClauseCosts *agg_costs, const AggClauseCosts *agg_costs,
grouping_sets_data *gd, int flags) grouping_sets_data *gd, int flags)
{ {
...@@ -3929,7 +3926,7 @@ create_ordinary_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel, ...@@ -3929,7 +3926,7 @@ create_ordinary_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
} }
/* Build final grouping paths */ /* Build final grouping paths */
add_paths_to_grouping_rel(root, input_rel, grouped_rel, target, add_paths_to_grouping_rel(root, input_rel, grouped_rel,
partially_grouped_rel, agg_costs, partially_grouped_rel, agg_costs,
&agg_final_costs, gd, can_sort, can_hash, &agg_final_costs, gd, can_sort, can_hash,
dNumGroups, (List *) parse->havingQual); dNumGroups, (List *) parse->havingQual);
...@@ -3968,7 +3965,6 @@ consider_groupingsets_paths(PlannerInfo *root, ...@@ -3968,7 +3965,6 @@ consider_groupingsets_paths(PlannerInfo *root,
Path *path, Path *path,
bool is_sorted, bool is_sorted,
bool can_hash, bool can_hash,
PathTarget *target,
grouping_sets_data *gd, grouping_sets_data *gd,
const AggClauseCosts *agg_costs, const AggClauseCosts *agg_costs,
double dNumGroups) double dNumGroups)
...@@ -4110,7 +4106,6 @@ consider_groupingsets_paths(PlannerInfo *root, ...@@ -4110,7 +4106,6 @@ consider_groupingsets_paths(PlannerInfo *root,
create_groupingsets_path(root, create_groupingsets_path(root,
grouped_rel, grouped_rel,
path, path,
target,
(List *) parse->havingQual, (List *) parse->havingQual,
strat, strat,
new_rollups, new_rollups,
...@@ -4268,7 +4263,6 @@ consider_groupingsets_paths(PlannerInfo *root, ...@@ -4268,7 +4263,6 @@ consider_groupingsets_paths(PlannerInfo *root,
create_groupingsets_path(root, create_groupingsets_path(root,
grouped_rel, grouped_rel,
path, path,
target,
(List *) parse->havingQual, (List *) parse->havingQual,
AGG_MIXED, AGG_MIXED,
rollups, rollups,
...@@ -4285,7 +4279,6 @@ consider_groupingsets_paths(PlannerInfo *root, ...@@ -4285,7 +4279,6 @@ consider_groupingsets_paths(PlannerInfo *root,
create_groupingsets_path(root, create_groupingsets_path(root,
grouped_rel, grouped_rel,
path, path,
target,
(List *) parse->havingQual, (List *) parse->havingQual,
AGG_SORTED, AGG_SORTED,
gd->rollups, gd->rollups,
...@@ -6087,7 +6080,6 @@ get_partitioned_child_rels_for_join(PlannerInfo *root, Relids join_relids) ...@@ -6087,7 +6080,6 @@ get_partitioned_child_rels_for_join(PlannerInfo *root, Relids join_relids)
static void static void
add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel, add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
RelOptInfo *grouped_rel, RelOptInfo *grouped_rel,
PathTarget *target,
RelOptInfo *partially_grouped_rel, RelOptInfo *partially_grouped_rel,
const AggClauseCosts *agg_costs, const AggClauseCosts *agg_costs,
const AggClauseCosts *agg_final_costs, const AggClauseCosts *agg_final_costs,
...@@ -6125,7 +6117,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel, ...@@ -6125,7 +6117,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
if (parse->groupingSets) if (parse->groupingSets)
{ {
consider_groupingsets_paths(root, grouped_rel, consider_groupingsets_paths(root, grouped_rel,
path, true, can_hash, target, path, true, can_hash,
gd, agg_costs, dNumGroups); gd, agg_costs, dNumGroups);
} }
else if (parse->hasAggs) else if (parse->hasAggs)
...@@ -6138,7 +6130,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel, ...@@ -6138,7 +6130,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
create_agg_path(root, create_agg_path(root,
grouped_rel, grouped_rel,
path, path,
target, grouped_rel->reltarget,
parse->groupClause ? AGG_SORTED : AGG_PLAIN, parse->groupClause ? AGG_SORTED : AGG_PLAIN,
AGGSPLIT_SIMPLE, AGGSPLIT_SIMPLE,
parse->groupClause, parse->groupClause,
...@@ -6156,7 +6148,6 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel, ...@@ -6156,7 +6148,6 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
create_group_path(root, create_group_path(root,
grouped_rel, grouped_rel,
path, path,
target,
parse->groupClause, parse->groupClause,
havingQual, havingQual,
dNumGroups)); dNumGroups));
...@@ -6199,7 +6190,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel, ...@@ -6199,7 +6190,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
create_agg_path(root, create_agg_path(root,
grouped_rel, grouped_rel,
path, path,
target, grouped_rel->reltarget,
parse->groupClause ? AGG_SORTED : AGG_PLAIN, parse->groupClause ? AGG_SORTED : AGG_PLAIN,
AGGSPLIT_FINAL_DESERIAL, AGGSPLIT_FINAL_DESERIAL,
parse->groupClause, parse->groupClause,
...@@ -6211,7 +6202,6 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel, ...@@ -6211,7 +6202,6 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
create_group_path(root, create_group_path(root,
grouped_rel, grouped_rel,
path, path,
target,
parse->groupClause, parse->groupClause,
havingQual, havingQual,
dNumGroups)); dNumGroups));
...@@ -6229,7 +6219,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel, ...@@ -6229,7 +6219,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
* Try for a hash-only groupingsets path over unsorted input. * Try for a hash-only groupingsets path over unsorted input.
*/ */
consider_groupingsets_paths(root, grouped_rel, consider_groupingsets_paths(root, grouped_rel,
cheapest_path, false, true, target, cheapest_path, false, true,
gd, agg_costs, dNumGroups); gd, agg_costs, dNumGroups);
} }
else else
...@@ -6254,7 +6244,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel, ...@@ -6254,7 +6244,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
add_path(grouped_rel, (Path *) add_path(grouped_rel, (Path *)
create_agg_path(root, grouped_rel, create_agg_path(root, grouped_rel,
cheapest_path, cheapest_path,
target, grouped_rel->reltarget,
AGG_HASHED, AGG_HASHED,
AGGSPLIT_SIMPLE, AGGSPLIT_SIMPLE,
parse->groupClause, parse->groupClause,
...@@ -6282,7 +6272,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel, ...@@ -6282,7 +6272,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
create_agg_path(root, create_agg_path(root,
grouped_rel, grouped_rel,
path, path,
target, grouped_rel->reltarget,
AGG_HASHED, AGG_HASHED,
AGGSPLIT_FINAL_DESERIAL, AGGSPLIT_FINAL_DESERIAL,
parse->groupClause, parse->groupClause,
...@@ -6420,7 +6410,6 @@ create_partial_grouping_paths(PlannerInfo *root, ...@@ -6420,7 +6410,6 @@ create_partial_grouping_paths(PlannerInfo *root,
create_group_path(root, create_group_path(root,
partially_grouped_rel, partially_grouped_rel,
path, path,
partially_grouped_rel->reltarget,
parse->groupClause, parse->groupClause,
NIL, NIL,
dNumPartialGroups)); dNumPartialGroups));
......
...@@ -2651,12 +2651,12 @@ GroupPath * ...@@ -2651,12 +2651,12 @@ GroupPath *
create_group_path(PlannerInfo *root, create_group_path(PlannerInfo *root,
RelOptInfo *rel, RelOptInfo *rel,
Path *subpath, Path *subpath,
PathTarget *target,
List *groupClause, List *groupClause,
List *qual, List *qual,
double numGroups) double numGroups)
{ {
GroupPath *pathnode = makeNode(GroupPath); GroupPath *pathnode = makeNode(GroupPath);
PathTarget *target = rel->reltarget;
pathnode->path.pathtype = T_Group; pathnode->path.pathtype = T_Group;
pathnode->path.parent = rel; pathnode->path.parent = rel;
...@@ -2828,7 +2828,6 @@ GroupingSetsPath * ...@@ -2828,7 +2828,6 @@ GroupingSetsPath *
create_groupingsets_path(PlannerInfo *root, create_groupingsets_path(PlannerInfo *root,
RelOptInfo *rel, RelOptInfo *rel,
Path *subpath, Path *subpath,
PathTarget *target,
List *having_qual, List *having_qual,
AggStrategy aggstrategy, AggStrategy aggstrategy,
List *rollups, List *rollups,
...@@ -2836,6 +2835,7 @@ create_groupingsets_path(PlannerInfo *root, ...@@ -2836,6 +2835,7 @@ create_groupingsets_path(PlannerInfo *root,
double numGroups) double numGroups)
{ {
GroupingSetsPath *pathnode = makeNode(GroupingSetsPath); GroupingSetsPath *pathnode = makeNode(GroupingSetsPath);
PathTarget *target = rel->reltarget;
ListCell *lc; ListCell *lc;
bool is_first = true; bool is_first = true;
bool is_first_sort = true; bool is_first_sort = true;
......
...@@ -178,7 +178,6 @@ extern SortPath *create_sort_path(PlannerInfo *root, ...@@ -178,7 +178,6 @@ extern SortPath *create_sort_path(PlannerInfo *root,
extern GroupPath *create_group_path(PlannerInfo *root, extern GroupPath *create_group_path(PlannerInfo *root,
RelOptInfo *rel, RelOptInfo *rel,
Path *subpath, Path *subpath,
PathTarget *target,
List *groupClause, List *groupClause,
List *qual, List *qual,
double numGroups); double numGroups);
...@@ -200,7 +199,6 @@ extern AggPath *create_agg_path(PlannerInfo *root, ...@@ -200,7 +199,6 @@ extern AggPath *create_agg_path(PlannerInfo *root,
extern GroupingSetsPath *create_groupingsets_path(PlannerInfo *root, extern GroupingSetsPath *create_groupingsets_path(PlannerInfo *root,
RelOptInfo *rel, RelOptInfo *rel,
Path *subpath, Path *subpath,
PathTarget *target,
List *having_qual, List *having_qual,
AggStrategy aggstrategy, AggStrategy aggstrategy,
List *rollups, List *rollups,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment