Skip to content

Commit 9415051

Browse files
committed
Don't pass the grouping target around unnecessarily.
Since commit 4f15e5d 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
1 parent b6cbe9e commit 9415051

File tree

3 files changed

+17
-30
lines changed

3 files changed

+17
-30
lines changed

src/backend/optimizer/plan/planner.c

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,17 @@ static RelOptInfo *create_grouping_paths(PlannerInfo *root,
163163
static bool is_degenerate_grouping(PlannerInfo *root);
164164
static void create_degenerate_grouping_paths(PlannerInfo *root,
165165
RelOptInfo *input_rel,
166-
PathTarget *target, RelOptInfo *grouped_rel);
166+
RelOptInfo *grouped_rel);
167167
static void create_ordinary_grouping_paths(PlannerInfo *root,
168168
RelOptInfo *input_rel,
169-
PathTarget *target, RelOptInfo *grouped_rel,
169+
RelOptInfo *grouped_rel,
170170
const AggClauseCosts *agg_costs,
171171
grouping_sets_data *gd, int flags);
172172
static void consider_groupingsets_paths(PlannerInfo *root,
173173
RelOptInfo *grouped_rel,
174174
Path *path,
175175
bool is_sorted,
176176
bool can_hash,
177-
PathTarget *target,
178177
grouping_sets_data *gd,
179178
const AggClauseCosts *agg_costs,
180179
double dNumGroups);
@@ -220,7 +219,6 @@ static void adjust_paths_for_srfs(PlannerInfo *root, RelOptInfo *rel,
220219
List *targets, List *targets_contain_srfs);
221220
static void add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
222221
RelOptInfo *grouped_rel,
223-
PathTarget *target,
224222
RelOptInfo *partially_grouped_rel,
225223
const AggClauseCosts *agg_costs,
226224
const AggClauseCosts *agg_final_costs,
@@ -3737,7 +3735,7 @@ create_grouping_paths(PlannerInfo *root,
37373735
* grouping, as appropriate.
37383736
*/
37393737
if (is_degenerate_grouping(root))
3740-
create_degenerate_grouping_paths(root, input_rel, target, grouped_rel);
3738+
create_degenerate_grouping_paths(root, input_rel, grouped_rel);
37413739
else
37423740
{
37433741
int flags = 0;
@@ -3788,7 +3786,7 @@ create_grouping_paths(PlannerInfo *root,
37883786
if (can_partial_agg(root, agg_costs))
37893787
flags |= GROUPING_CAN_PARTIAL_AGG;
37903788

3791-
create_ordinary_grouping_paths(root, input_rel, target, grouped_rel,
3789+
create_ordinary_grouping_paths(root, input_rel, grouped_rel,
37923790
agg_costs, gd, flags);
37933791
}
37943792

@@ -3826,7 +3824,7 @@ is_degenerate_grouping(PlannerInfo *root)
38263824
*/
38273825
static void
38283826
create_degenerate_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
3829-
PathTarget *target, RelOptInfo *grouped_rel)
3827+
RelOptInfo *grouped_rel)
38303828
{
38313829
Query *parse = root->parse;
38323830
int nrows;
@@ -3848,7 +3846,7 @@ create_degenerate_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
38483846
{
38493847
path = (Path *)
38503848
create_result_path(root, grouped_rel,
3851-
target,
3849+
grouped_rel->reltarget,
38523850
(List *) parse->havingQual);
38533851
paths = lappend(paths, path);
38543852
}
@@ -3861,14 +3859,13 @@ create_degenerate_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
38613859
false,
38623860
NIL,
38633861
-1);
3864-
path->pathtarget = target;
38653862
}
38663863
else
38673864
{
38683865
/* No grouping sets, or just one, so one output row */
38693866
path = (Path *)
38703867
create_result_path(root, grouped_rel,
3871-
target,
3868+
grouped_rel->reltarget,
38723869
(List *) parse->havingQual);
38733870
}
38743871

@@ -3887,7 +3884,7 @@ create_degenerate_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
38873884
*/
38883885
static void
38893886
create_ordinary_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
3890-
PathTarget *target, RelOptInfo *grouped_rel,
3887+
RelOptInfo *grouped_rel,
38913888
const AggClauseCosts *agg_costs,
38923889
grouping_sets_data *gd, int flags)
38933890
{
@@ -3929,7 +3926,7 @@ create_ordinary_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel,
39293926
}
39303927

39313928
/* Build final grouping paths */
3932-
add_paths_to_grouping_rel(root, input_rel, grouped_rel, target,
3929+
add_paths_to_grouping_rel(root, input_rel, grouped_rel,
39333930
partially_grouped_rel, agg_costs,
39343931
&agg_final_costs, gd, can_sort, can_hash,
39353932
dNumGroups, (List *) parse->havingQual);
@@ -3968,7 +3965,6 @@ consider_groupingsets_paths(PlannerInfo *root,
39683965
Path *path,
39693966
bool is_sorted,
39703967
bool can_hash,
3971-
PathTarget *target,
39723968
grouping_sets_data *gd,
39733969
const AggClauseCosts *agg_costs,
39743970
double dNumGroups)
@@ -4110,7 +4106,6 @@ consider_groupingsets_paths(PlannerInfo *root,
41104106
create_groupingsets_path(root,
41114107
grouped_rel,
41124108
path,
4113-
target,
41144109
(List *) parse->havingQual,
41154110
strat,
41164111
new_rollups,
@@ -4268,7 +4263,6 @@ consider_groupingsets_paths(PlannerInfo *root,
42684263
create_groupingsets_path(root,
42694264
grouped_rel,
42704265
path,
4271-
target,
42724266
(List *) parse->havingQual,
42734267
AGG_MIXED,
42744268
rollups,
@@ -4285,7 +4279,6 @@ consider_groupingsets_paths(PlannerInfo *root,
42854279
create_groupingsets_path(root,
42864280
grouped_rel,
42874281
path,
4288-
target,
42894282
(List *) parse->havingQual,
42904283
AGG_SORTED,
42914284
gd->rollups,
@@ -6087,7 +6080,6 @@ get_partitioned_child_rels_for_join(PlannerInfo *root, Relids join_relids)
60876080
static void
60886081
add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
60896082
RelOptInfo *grouped_rel,
6090-
PathTarget *target,
60916083
RelOptInfo *partially_grouped_rel,
60926084
const AggClauseCosts *agg_costs,
60936085
const AggClauseCosts *agg_final_costs,
@@ -6125,7 +6117,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
61256117
if (parse->groupingSets)
61266118
{
61276119
consider_groupingsets_paths(root, grouped_rel,
6128-
path, true, can_hash, target,
6120+
path, true, can_hash,
61296121
gd, agg_costs, dNumGroups);
61306122
}
61316123
else if (parse->hasAggs)
@@ -6138,7 +6130,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
61386130
create_agg_path(root,
61396131
grouped_rel,
61406132
path,
6141-
target,
6133+
grouped_rel->reltarget,
61426134
parse->groupClause ? AGG_SORTED : AGG_PLAIN,
61436135
AGGSPLIT_SIMPLE,
61446136
parse->groupClause,
@@ -6156,7 +6148,6 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
61566148
create_group_path(root,
61576149
grouped_rel,
61586150
path,
6159-
target,
61606151
parse->groupClause,
61616152
havingQual,
61626153
dNumGroups));
@@ -6199,7 +6190,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
61996190
create_agg_path(root,
62006191
grouped_rel,
62016192
path,
6202-
target,
6193+
grouped_rel->reltarget,
62036194
parse->groupClause ? AGG_SORTED : AGG_PLAIN,
62046195
AGGSPLIT_FINAL_DESERIAL,
62056196
parse->groupClause,
@@ -6211,7 +6202,6 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
62116202
create_group_path(root,
62126203
grouped_rel,
62136204
path,
6214-
target,
62156205
parse->groupClause,
62166206
havingQual,
62176207
dNumGroups));
@@ -6229,7 +6219,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
62296219
* Try for a hash-only groupingsets path over unsorted input.
62306220
*/
62316221
consider_groupingsets_paths(root, grouped_rel,
6232-
cheapest_path, false, true, target,
6222+
cheapest_path, false, true,
62336223
gd, agg_costs, dNumGroups);
62346224
}
62356225
else
@@ -6254,7 +6244,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
62546244
add_path(grouped_rel, (Path *)
62556245
create_agg_path(root, grouped_rel,
62566246
cheapest_path,
6257-
target,
6247+
grouped_rel->reltarget,
62586248
AGG_HASHED,
62596249
AGGSPLIT_SIMPLE,
62606250
parse->groupClause,
@@ -6282,7 +6272,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
62826272
create_agg_path(root,
62836273
grouped_rel,
62846274
path,
6285-
target,
6275+
grouped_rel->reltarget,
62866276
AGG_HASHED,
62876277
AGGSPLIT_FINAL_DESERIAL,
62886278
parse->groupClause,
@@ -6420,7 +6410,6 @@ create_partial_grouping_paths(PlannerInfo *root,
64206410
create_group_path(root,
64216411
partially_grouped_rel,
64226412
path,
6423-
partially_grouped_rel->reltarget,
64246413
parse->groupClause,
64256414
NIL,
64266415
dNumPartialGroups));

src/backend/optimizer/util/pathnode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2651,12 +2651,12 @@ GroupPath *
26512651
create_group_path(PlannerInfo *root,
26522652
RelOptInfo *rel,
26532653
Path *subpath,
2654-
PathTarget *target,
26552654
List *groupClause,
26562655
List *qual,
26572656
double numGroups)
26582657
{
26592658
GroupPath *pathnode = makeNode(GroupPath);
2659+
PathTarget *target = rel->reltarget;
26602660

26612661
pathnode->path.pathtype = T_Group;
26622662
pathnode->path.parent = rel;
@@ -2828,14 +2828,14 @@ GroupingSetsPath *
28282828
create_groupingsets_path(PlannerInfo *root,
28292829
RelOptInfo *rel,
28302830
Path *subpath,
2831-
PathTarget *target,
28322831
List *having_qual,
28332832
AggStrategy aggstrategy,
28342833
List *rollups,
28352834
const AggClauseCosts *agg_costs,
28362835
double numGroups)
28372836
{
28382837
GroupingSetsPath *pathnode = makeNode(GroupingSetsPath);
2838+
PathTarget *target = rel->reltarget;
28392839
ListCell *lc;
28402840
bool is_first = true;
28412841
bool is_first_sort = true;

src/include/optimizer/pathnode.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ extern SortPath *create_sort_path(PlannerInfo *root,
178178
extern GroupPath *create_group_path(PlannerInfo *root,
179179
RelOptInfo *rel,
180180
Path *subpath,
181-
PathTarget *target,
182181
List *groupClause,
183182
List *qual,
184183
double numGroups);
@@ -200,7 +199,6 @@ extern AggPath *create_agg_path(PlannerInfo *root,
200199
extern GroupingSetsPath *create_groupingsets_path(PlannerInfo *root,
201200
RelOptInfo *rel,
202201
Path *subpath,
203-
PathTarget *target,
204202
List *having_qual,
205203
AggStrategy aggstrategy,
206204
List *rollups,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy