Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 18fea73

Browse files
committed
Change NestPath node to contain JoinPath node
This makes the structure of all JoinPath-derived nodes the same, independent of whether they have additional fields. Discussion: https://www.postgresql.org/message-id/flat/c1097590-a6a4-486a-64b1-e1f9cc0533ce@enterprisedb.com
1 parent 2226b41 commit 18fea73

File tree

4 files changed

+51
-45
lines changed

4 files changed

+51
-45
lines changed

src/backend/optimizer/path/costsize.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ static bool cost_qual_eval_walker(Node *node, cost_qual_eval_context *context);
167167
static void get_restriction_qual_cost(PlannerInfo *root, RelOptInfo *baserel,
168168
ParamPathInfo *param_info,
169169
QualCost *qpqual_cost);
170-
static bool has_indexed_join_quals(NestPath *joinpath);
170+
static bool has_indexed_join_quals(NestPath *path);
171171
static double approx_tuple_count(PlannerInfo *root, JoinPath *path,
172172
List *quals);
173173
static double calc_joinrel_size_estimate(PlannerInfo *root,
@@ -2978,8 +2978,8 @@ final_cost_nestloop(PlannerInfo *root, NestPath *path,
29782978
JoinCostWorkspace *workspace,
29792979
JoinPathExtraData *extra)
29802980
{
2981-
Path *outer_path = path->outerjoinpath;
2982-
Path *inner_path = path->innerjoinpath;
2981+
Path *outer_path = path->jpath.outerjoinpath;
2982+
Path *inner_path = path->jpath.innerjoinpath;
29832983
double outer_path_rows = outer_path->rows;
29842984
double inner_path_rows = inner_path->rows;
29852985
Cost startup_cost = workspace->startup_cost;
@@ -2994,18 +2994,18 @@ final_cost_nestloop(PlannerInfo *root, NestPath *path,
29942994
if (inner_path_rows <= 0)
29952995
inner_path_rows = 1;
29962996
/* Mark the path with the correct row estimate */
2997-
if (path->path.param_info)
2998-
path->path.rows = path->path.param_info->ppi_rows;
2997+
if (path->jpath.path.param_info)
2998+
path->jpath.path.rows = path->jpath.path.param_info->ppi_rows;
29992999
else
3000-
path->path.rows = path->path.parent->rows;
3000+
path->jpath.path.rows = path->jpath.path.parent->rows;
30013001

30023002
/* For partial paths, scale row estimate. */
3003-
if (path->path.parallel_workers > 0)
3003+
if (path->jpath.path.parallel_workers > 0)
30043004
{
3005-
double parallel_divisor = get_parallel_divisor(&path->path);
3005+
double parallel_divisor = get_parallel_divisor(&path->jpath.path);
30063006

3007-
path->path.rows =
3008-
clamp_row_est(path->path.rows / parallel_divisor);
3007+
path->jpath.path.rows =
3008+
clamp_row_est(path->jpath.path.rows / parallel_divisor);
30093009
}
30103010

30113011
/*
@@ -3018,7 +3018,7 @@ final_cost_nestloop(PlannerInfo *root, NestPath *path,
30183018

30193019
/* cost of inner-relation source data (we already dealt with outer rel) */
30203020

3021-
if (path->jointype == JOIN_SEMI || path->jointype == JOIN_ANTI ||
3021+
if (path->jpath.jointype == JOIN_SEMI || path->jpath.jointype == JOIN_ANTI ||
30223022
extra->inner_unique)
30233023
{
30243024
/*
@@ -3136,17 +3136,17 @@ final_cost_nestloop(PlannerInfo *root, NestPath *path,
31363136
}
31373137

31383138
/* CPU costs */
3139-
cost_qual_eval(&restrict_qual_cost, path->joinrestrictinfo, root);
3139+
cost_qual_eval(&restrict_qual_cost, path->jpath.joinrestrictinfo, root);
31403140
startup_cost += restrict_qual_cost.startup;
31413141
cpu_per_tuple = cpu_tuple_cost + restrict_qual_cost.per_tuple;
31423142
run_cost += cpu_per_tuple * ntuples;
31433143

31443144
/* tlist eval costs are paid per output row, not per tuple scanned */
3145-
startup_cost += path->path.pathtarget->cost.startup;
3146-
run_cost += path->path.pathtarget->cost.per_tuple * path->path.rows;
3145+
startup_cost += path->jpath.path.pathtarget->cost.startup;
3146+
run_cost += path->jpath.path.pathtarget->cost.per_tuple * path->jpath.path.rows;
31473147

3148-
path->path.startup_cost = startup_cost;
3149-
path->path.total_cost = startup_cost + run_cost;
3148+
path->jpath.path.startup_cost = startup_cost;
3149+
path->jpath.path.total_cost = startup_cost + run_cost;
31503150
}
31513151

31523152
/*
@@ -4771,8 +4771,9 @@ compute_semi_anti_join_factors(PlannerInfo *root,
47714771
* expensive.
47724772
*/
47734773
static bool
4774-
has_indexed_join_quals(NestPath *joinpath)
4774+
has_indexed_join_quals(NestPath *path)
47754775
{
4776+
JoinPath *joinpath = &path->jpath;
47764777
Relids joinrelids = joinpath->path.parent->relids;
47774778
Path *innerpath = joinpath->innerjoinpath;
47784779
List *indexclauses;

src/backend/optimizer/plan/createplan.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4221,22 +4221,22 @@ create_nestloop_plan(PlannerInfo *root,
42214221
NestLoop *join_plan;
42224222
Plan *outer_plan;
42234223
Plan *inner_plan;
4224-
List *tlist = build_path_tlist(root, &best_path->path);
4225-
List *joinrestrictclauses = best_path->joinrestrictinfo;
4224+
List *tlist = build_path_tlist(root, &best_path->jpath.path);
4225+
List *joinrestrictclauses = best_path->jpath.joinrestrictinfo;
42264226
List *joinclauses;
42274227
List *otherclauses;
42284228
Relids outerrelids;
42294229
List *nestParams;
42304230
Relids saveOuterRels = root->curOuterRels;
42314231

42324232
/* NestLoop can project, so no need to be picky about child tlists */
4233-
outer_plan = create_plan_recurse(root, best_path->outerjoinpath, 0);
4233+
outer_plan = create_plan_recurse(root, best_path->jpath.outerjoinpath, 0);
42344234

42354235
/* For a nestloop, include outer relids in curOuterRels for inner side */
42364236
root->curOuterRels = bms_union(root->curOuterRels,
4237-
best_path->outerjoinpath->parent->relids);
4237+
best_path->jpath.outerjoinpath->parent->relids);
42384238

4239-
inner_plan = create_plan_recurse(root, best_path->innerjoinpath, 0);
4239+
inner_plan = create_plan_recurse(root, best_path->jpath.innerjoinpath, 0);
42404240

42414241
/* Restore curOuterRels */
42424242
bms_free(root->curOuterRels);
@@ -4247,10 +4247,10 @@ create_nestloop_plan(PlannerInfo *root,
42474247

42484248
/* Get the join qual clauses (in plain expression form) */
42494249
/* Any pseudoconstant clauses are ignored here */
4250-
if (IS_OUTER_JOIN(best_path->jointype))
4250+
if (IS_OUTER_JOIN(best_path->jpath.jointype))
42514251
{
42524252
extract_actual_join_clauses(joinrestrictclauses,
4253-
best_path->path.parent->relids,
4253+
best_path->jpath.path.parent->relids,
42544254
&joinclauses, &otherclauses);
42554255
}
42564256
else
@@ -4261,7 +4261,7 @@ create_nestloop_plan(PlannerInfo *root,
42614261
}
42624262

42634263
/* Replace any outer-relation variables with nestloop params */
4264-
if (best_path->path.param_info)
4264+
if (best_path->jpath.path.param_info)
42654265
{
42664266
joinclauses = (List *)
42674267
replace_nestloop_params(root, (Node *) joinclauses);
@@ -4273,7 +4273,7 @@ create_nestloop_plan(PlannerInfo *root,
42734273
* Identify any nestloop parameters that should be supplied by this join
42744274
* node, and remove them from root->curOuterParams.
42754275
*/
4276-
outerrelids = best_path->outerjoinpath->parent->relids;
4276+
outerrelids = best_path->jpath.outerjoinpath->parent->relids;
42774277
nestParams = identify_current_nestloop_params(root, outerrelids);
42784278

42794279
join_plan = make_nestloop(tlist,
@@ -4282,10 +4282,10 @@ create_nestloop_plan(PlannerInfo *root,
42824282
nestParams,
42834283
outer_plan,
42844284
inner_plan,
4285-
best_path->jointype,
4286-
best_path->inner_unique);
4285+
best_path->jpath.jointype,
4286+
best_path->jpath.inner_unique);
42874287

4288-
copy_generic_path_info(&join_plan->join.plan, &best_path->path);
4288+
copy_generic_path_info(&join_plan->join.plan, &best_path->jpath.path);
42894289

42904290
return join_plan;
42914291
}

src/backend/optimizer/util/pathnode.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2443,28 +2443,28 @@ create_nestloop_path(PlannerInfo *root,
24432443
restrict_clauses = jclauses;
24442444
}
24452445

2446-
pathnode->path.pathtype = T_NestLoop;
2447-
pathnode->path.parent = joinrel;
2448-
pathnode->path.pathtarget = joinrel->reltarget;
2449-
pathnode->path.param_info =
2446+
pathnode->jpath.path.pathtype = T_NestLoop;
2447+
pathnode->jpath.path.parent = joinrel;
2448+
pathnode->jpath.path.pathtarget = joinrel->reltarget;
2449+
pathnode->jpath.path.param_info =
24502450
get_joinrel_parampathinfo(root,
24512451
joinrel,
24522452
outer_path,
24532453
inner_path,
24542454
extra->sjinfo,
24552455
required_outer,
24562456
&restrict_clauses);
2457-
pathnode->path.parallel_aware = false;
2458-
pathnode->path.parallel_safe = joinrel->consider_parallel &&
2457+
pathnode->jpath.path.parallel_aware = false;
2458+
pathnode->jpath.path.parallel_safe = joinrel->consider_parallel &&
24592459
outer_path->parallel_safe && inner_path->parallel_safe;
24602460
/* This is a foolish way to estimate parallel_workers, but for now... */
2461-
pathnode->path.parallel_workers = outer_path->parallel_workers;
2462-
pathnode->path.pathkeys = pathkeys;
2463-
pathnode->jointype = jointype;
2464-
pathnode->inner_unique = extra->inner_unique;
2465-
pathnode->outerjoinpath = outer_path;
2466-
pathnode->innerjoinpath = inner_path;
2467-
pathnode->joinrestrictinfo = restrict_clauses;
2461+
pathnode->jpath.path.parallel_workers = outer_path->parallel_workers;
2462+
pathnode->jpath.path.pathkeys = pathkeys;
2463+
pathnode->jpath.jointype = jointype;
2464+
pathnode->jpath.inner_unique = extra->inner_unique;
2465+
pathnode->jpath.outerjoinpath = outer_path;
2466+
pathnode->jpath.innerjoinpath = inner_path;
2467+
pathnode->jpath.joinrestrictinfo = restrict_clauses;
24682468

24692469
final_cost_nestloop(root, pathnode, workspace, extra);
24702470

@@ -4110,13 +4110,15 @@ do { \
41104110
case T_NestPath:
41114111
{
41124112
JoinPath *jpath;
4113+
NestPath *npath;
41134114

4114-
FLAT_COPY_PATH(jpath, path, NestPath);
4115+
FLAT_COPY_PATH(npath, path, NestPath);
41154116

4117+
jpath = (JoinPath *) npath;
41164118
REPARAMETERIZE_CHILD_PATH(jpath->outerjoinpath);
41174119
REPARAMETERIZE_CHILD_PATH(jpath->innerjoinpath);
41184120
ADJUST_CHILD_ATTRS(jpath->joinrestrictinfo);
4119-
new_path = (Path *) jpath;
4121+
new_path = (Path *) npath;
41204122
}
41214123
break;
41224124

src/include/nodes/pathnodes.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,10 @@ typedef struct JoinPath
15981598
* A nested-loop path needs no special fields.
15991599
*/
16001600

1601-
typedef JoinPath NestPath;
1601+
typedef struct NestPath
1602+
{
1603+
JoinPath jpath;
1604+
} NestPath;
16021605

16031606
/*
16041607
* A mergejoin path has these fields.

0 commit comments

Comments
 (0)