mirror of
https://github.com/postgres/postgres.git
synced 2025-07-14 08:21:07 +03:00
Rethink representation of PathTargets.
In commit 19a541143a
I did not make PathTarget a subtype of Node,
and embedded a RelOptInfo's reltarget directly into it rather than having
a separately-allocated Node. In hindsight that was misguided
micro-optimization, enabled by the fact that at that point we didn't have
any Paths with custom PathTargets. Now that PathTarget processing has
been fleshed out some more, it's easier to see that it's better to have
PathTarget as an indepedent Node type, even if it does cost us one more
palloc to create a RelOptInfo. So change it while we still can.
This commit just changes the representation, without doing anything more
interesting than that.
This commit is contained in:
@ -936,7 +936,7 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
|
||||
/*
|
||||
* CE failed, so finish copying/modifying targetlist and join quals.
|
||||
*
|
||||
* Note: the resulting childrel->reltarget.exprs may contain arbitrary
|
||||
* NB: the resulting childrel->reltarget->exprs may contain arbitrary
|
||||
* expressions, which otherwise would not occur in a rel's targetlist.
|
||||
* Code that might be looking at an appendrel child must cope with
|
||||
* such. (Normally, a rel's targetlist would only include Vars and
|
||||
@ -947,9 +947,9 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
|
||||
adjust_appendrel_attrs(root,
|
||||
(Node *) rel->joininfo,
|
||||
appinfo);
|
||||
childrel->reltarget.exprs = (List *)
|
||||
childrel->reltarget->exprs = (List *)
|
||||
adjust_appendrel_attrs(root,
|
||||
(Node *) rel->reltarget.exprs,
|
||||
(Node *) rel->reltarget->exprs,
|
||||
appinfo);
|
||||
|
||||
/*
|
||||
@ -994,7 +994,7 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
|
||||
Assert(childrel->rows > 0);
|
||||
|
||||
parent_rows += childrel->rows;
|
||||
parent_size += childrel->reltarget.width * childrel->rows;
|
||||
parent_size += childrel->reltarget->width * childrel->rows;
|
||||
|
||||
/*
|
||||
* Accumulate per-column estimates too. We need not do anything for
|
||||
@ -1004,8 +1004,8 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
|
||||
*
|
||||
* By construction, child's targetlist is 1-to-1 with parent's.
|
||||
*/
|
||||
forboth(parentvars, rel->reltarget.exprs,
|
||||
childvars, childrel->reltarget.exprs)
|
||||
forboth(parentvars, rel->reltarget->exprs,
|
||||
childvars, childrel->reltarget->exprs)
|
||||
{
|
||||
Var *parentvar = (Var *) lfirst(parentvars);
|
||||
Node *childvar = (Node *) lfirst(childvars);
|
||||
@ -1040,7 +1040,7 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
|
||||
|
||||
Assert(parent_rows > 0);
|
||||
rel->rows = parent_rows;
|
||||
rel->reltarget.width = rint(parent_size / parent_rows);
|
||||
rel->reltarget->width = rint(parent_size / parent_rows);
|
||||
for (i = 0; i < nattrs; i++)
|
||||
rel->attr_widths[i] = rint(parent_attrsizes[i] / parent_rows);
|
||||
|
||||
@ -1515,7 +1515,7 @@ set_dummy_rel_pathlist(RelOptInfo *rel)
|
||||
{
|
||||
/* Set dummy size estimates --- we leave attr_widths[] as zeroes */
|
||||
rel->rows = 0;
|
||||
rel->reltarget.width = 0;
|
||||
rel->reltarget->width = 0;
|
||||
|
||||
/* Discard any pre-existing paths; no further need for them */
|
||||
rel->pathlist = NIL;
|
||||
@ -1771,7 +1771,7 @@ set_function_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
|
||||
* not reference the ordinality column, or at least not in any way
|
||||
* that would be interesting for sorting.
|
||||
*/
|
||||
foreach(lc, rel->reltarget.exprs)
|
||||
foreach(lc, rel->reltarget->exprs)
|
||||
{
|
||||
Var *node = (Var *) lfirst(lc);
|
||||
|
||||
@ -2717,7 +2717,7 @@ remove_unused_subquery_outputs(Query *subquery, RelOptInfo *rel)
|
||||
* isn't computed for inheritance child rels, cf set_append_rel_size().
|
||||
* (XXX might be worth changing that sometime.)
|
||||
*/
|
||||
pull_varattnos((Node *) rel->reltarget.exprs, rel->relid, &attrs_used);
|
||||
pull_varattnos((Node *) rel->reltarget->exprs, rel->relid, &attrs_used);
|
||||
|
||||
/* Add all the attributes used by un-pushed-down restriction clauses. */
|
||||
foreach(lc, rel->baserestrictinfo)
|
||||
@ -3028,7 +3028,7 @@ debug_print_rel(PlannerInfo *root, RelOptInfo *rel)
|
||||
|
||||
printf("RELOPTINFO (");
|
||||
print_relids(rel->relids);
|
||||
printf("): rows=%.0f width=%d\n", rel->rows, rel->reltarget.width);
|
||||
printf("): rows=%.0f width=%d\n", rel->rows, rel->reltarget->width);
|
||||
|
||||
if (rel->baserestrictinfo)
|
||||
{
|
||||
|
@ -4218,7 +4218,7 @@ set_foreign_size_estimates(PlannerInfo *root, RelOptInfo *rel)
|
||||
* that have to be calculated at this relation. This is the amount of data
|
||||
* we'd need to pass upwards in case of a sort, hash, etc.
|
||||
*
|
||||
* This function also sets reltarget.cost, so it's a bit misnamed now.
|
||||
* This function also sets reltarget->cost, so it's a bit misnamed now.
|
||||
*
|
||||
* NB: this works best on plain relations because it prefers to look at
|
||||
* real Vars. For subqueries, set_subquery_size_estimates will already have
|
||||
@ -4239,10 +4239,10 @@ set_rel_width(PlannerInfo *root, RelOptInfo *rel)
|
||||
ListCell *lc;
|
||||
|
||||
/* Vars are assumed to have cost zero, but other exprs do not */
|
||||
rel->reltarget.cost.startup = 0;
|
||||
rel->reltarget.cost.per_tuple = 0;
|
||||
rel->reltarget->cost.startup = 0;
|
||||
rel->reltarget->cost.per_tuple = 0;
|
||||
|
||||
foreach(lc, rel->reltarget.exprs)
|
||||
foreach(lc, rel->reltarget->exprs)
|
||||
{
|
||||
Node *node = (Node *) lfirst(lc);
|
||||
|
||||
@ -4309,7 +4309,7 @@ set_rel_width(PlannerInfo *root, RelOptInfo *rel)
|
||||
{
|
||||
/*
|
||||
* We will need to evaluate the PHV's contained expression while
|
||||
* scanning this rel, so be sure to include it in reltarget.cost.
|
||||
* scanning this rel, so be sure to include it in reltarget->cost.
|
||||
*/
|
||||
PlaceHolderVar *phv = (PlaceHolderVar *) node;
|
||||
PlaceHolderInfo *phinfo = find_placeholder_info(root, phv, false);
|
||||
@ -4317,8 +4317,8 @@ set_rel_width(PlannerInfo *root, RelOptInfo *rel)
|
||||
|
||||
tuple_width += phinfo->ph_width;
|
||||
cost_qual_eval_node(&cost, (Node *) phv->phexpr, root);
|
||||
rel->reltarget.cost.startup += cost.startup;
|
||||
rel->reltarget.cost.per_tuple += cost.per_tuple;
|
||||
rel->reltarget->cost.startup += cost.startup;
|
||||
rel->reltarget->cost.per_tuple += cost.per_tuple;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -4335,8 +4335,8 @@ set_rel_width(PlannerInfo *root, RelOptInfo *rel)
|
||||
tuple_width += item_width;
|
||||
/* Not entirely clear if we need to account for cost, but do so */
|
||||
cost_qual_eval_node(&cost, node, root);
|
||||
rel->reltarget.cost.startup += cost.startup;
|
||||
rel->reltarget.cost.per_tuple += cost.per_tuple;
|
||||
rel->reltarget->cost.startup += cost.startup;
|
||||
rel->reltarget->cost.per_tuple += cost.per_tuple;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4373,7 +4373,7 @@ set_rel_width(PlannerInfo *root, RelOptInfo *rel)
|
||||
}
|
||||
|
||||
Assert(tuple_width >= 0);
|
||||
rel->reltarget.width = tuple_width;
|
||||
rel->reltarget->width = tuple_width;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1550,7 +1550,7 @@ bitmap_scan_cost_est(PlannerInfo *root, RelOptInfo *rel, Path *ipath)
|
||||
bpath.path.type = T_BitmapHeapPath;
|
||||
bpath.path.pathtype = T_BitmapHeapScan;
|
||||
bpath.path.parent = rel;
|
||||
bpath.path.pathtarget = &(rel->reltarget);
|
||||
bpath.path.pathtarget = rel->reltarget;
|
||||
bpath.path.param_info = get_baserel_parampathinfo(root, rel,
|
||||
required_outer);
|
||||
bpath.path.pathkeys = NIL;
|
||||
@ -1579,7 +1579,7 @@ bitmap_and_cost_est(PlannerInfo *root, RelOptInfo *rel, List *paths)
|
||||
apath.path.type = T_BitmapAndPath;
|
||||
apath.path.pathtype = T_BitmapAnd;
|
||||
apath.path.parent = rel;
|
||||
apath.path.pathtarget = &(rel->reltarget);
|
||||
apath.path.pathtarget = rel->reltarget;
|
||||
apath.path.param_info = NULL; /* not used in bitmap trees */
|
||||
apath.path.pathkeys = NIL;
|
||||
apath.bitmapquals = paths;
|
||||
@ -1592,7 +1592,7 @@ bitmap_and_cost_est(PlannerInfo *root, RelOptInfo *rel, List *paths)
|
||||
bpath.path.type = T_BitmapHeapPath;
|
||||
bpath.path.pathtype = T_BitmapHeapScan;
|
||||
bpath.path.parent = rel;
|
||||
bpath.path.pathtarget = &(rel->reltarget);
|
||||
bpath.path.pathtarget = rel->reltarget;
|
||||
bpath.path.param_info = get_baserel_parampathinfo(root, rel,
|
||||
required_outer);
|
||||
bpath.path.pathkeys = NIL;
|
||||
@ -1815,7 +1815,7 @@ check_index_only(RelOptInfo *rel, IndexOptInfo *index)
|
||||
* look at rel's targetlist, not the attr_needed data, because attr_needed
|
||||
* isn't computed for inheritance child rels.
|
||||
*/
|
||||
pull_varattnos((Node *) rel->reltarget.exprs, rel->relid, &attrs_used);
|
||||
pull_varattnos((Node *) rel->reltarget->exprs, rel->relid, &attrs_used);
|
||||
|
||||
/* Add all the attributes used by restriction clauses. */
|
||||
foreach(lc, rel->baserestrictinfo)
|
||||
|
@ -3279,7 +3279,7 @@ create_foreignscan_plan(PlannerInfo *root, ForeignPath *best_path,
|
||||
* Note: we must look at rel's targetlist, not the attr_needed data,
|
||||
* because attr_needed isn't computed for inheritance child rels.
|
||||
*/
|
||||
pull_varattnos((Node *) rel->reltarget.exprs, scan_relid, &attrs_used);
|
||||
pull_varattnos((Node *) rel->reltarget->exprs, scan_relid, &attrs_used);
|
||||
|
||||
/* Add all the attributes used by restriction clauses. */
|
||||
foreach(lc, rel->baserestrictinfo)
|
||||
|
@ -215,8 +215,8 @@ add_vars_to_targetlist(PlannerInfo *root, List *vars,
|
||||
{
|
||||
/* Variable not yet requested, so add to rel's targetlist */
|
||||
/* XXX is copyObject necessary here? */
|
||||
rel->reltarget.exprs = lappend(rel->reltarget.exprs,
|
||||
copyObject(var));
|
||||
rel->reltarget->exprs = lappend(rel->reltarget->exprs,
|
||||
copyObject(var));
|
||||
/* reltarget cost and width will be computed later */
|
||||
}
|
||||
rel->attr_needed[attno] = bms_add_members(rel->attr_needed[attno],
|
||||
|
@ -83,7 +83,7 @@ query_planner(PlannerInfo *root, List *tlist,
|
||||
/* The only path for it is a trivial Result path */
|
||||
add_path(final_rel, (Path *)
|
||||
create_result_path(root, final_rel,
|
||||
&(final_rel->reltarget),
|
||||
final_rel->reltarget,
|
||||
(List *) parse->jointree->quals));
|
||||
|
||||
/* Select cheapest path (pretty easy in this case...) */
|
||||
|
@ -4534,7 +4534,7 @@ plan_cluster_use_sort(Oid tableOid, Oid indexOid)
|
||||
* set_baserel_size_estimates, just do a quick hack for rows and width.
|
||||
*/
|
||||
rel->rows = rel->tuples;
|
||||
rel->reltarget.width = get_relation_data_width(tableOid, NULL);
|
||||
rel->reltarget->width = get_relation_data_width(tableOid, NULL);
|
||||
|
||||
root->total_table_pages = rel->pages;
|
||||
|
||||
@ -4550,7 +4550,7 @@ plan_cluster_use_sort(Oid tableOid, Oid indexOid)
|
||||
/* Estimate the cost of seq scan + sort */
|
||||
seqScanPath = create_seqscan_path(root, rel, NULL, 0);
|
||||
cost_sort(&seqScanAndSortPath, root, NIL,
|
||||
seqScanPath->total_cost, rel->tuples, rel->reltarget.width,
|
||||
seqScanPath->total_cost, rel->tuples, rel->reltarget->width,
|
||||
comparisonCost, maintenance_work_mem, -1.0);
|
||||
|
||||
/* Estimate the cost of index scan */
|
||||
|
@ -929,7 +929,7 @@ create_seqscan_path(PlannerInfo *root, RelOptInfo *rel,
|
||||
|
||||
pathnode->pathtype = T_SeqScan;
|
||||
pathnode->parent = rel;
|
||||
pathnode->pathtarget = &(rel->reltarget);
|
||||
pathnode->pathtarget = rel->reltarget;
|
||||
pathnode->param_info = get_baserel_parampathinfo(root, rel,
|
||||
required_outer);
|
||||
pathnode->parallel_aware = parallel_degree > 0 ? true : false;
|
||||
@ -953,7 +953,7 @@ create_samplescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer
|
||||
|
||||
pathnode->pathtype = T_SampleScan;
|
||||
pathnode->parent = rel;
|
||||
pathnode->pathtarget = &(rel->reltarget);
|
||||
pathnode->pathtarget = rel->reltarget;
|
||||
pathnode->param_info = get_baserel_parampathinfo(root, rel,
|
||||
required_outer);
|
||||
pathnode->parallel_aware = false;
|
||||
@ -1010,7 +1010,7 @@ create_index_path(PlannerInfo *root,
|
||||
|
||||
pathnode->path.pathtype = indexonly ? T_IndexOnlyScan : T_IndexScan;
|
||||
pathnode->path.parent = rel;
|
||||
pathnode->path.pathtarget = &(rel->reltarget);
|
||||
pathnode->path.pathtarget = rel->reltarget;
|
||||
pathnode->path.param_info = get_baserel_parampathinfo(root, rel,
|
||||
required_outer);
|
||||
pathnode->path.parallel_aware = false;
|
||||
@ -1059,7 +1059,7 @@ create_bitmap_heap_path(PlannerInfo *root,
|
||||
|
||||
pathnode->path.pathtype = T_BitmapHeapScan;
|
||||
pathnode->path.parent = rel;
|
||||
pathnode->path.pathtarget = &(rel->reltarget);
|
||||
pathnode->path.pathtarget = rel->reltarget;
|
||||
pathnode->path.param_info = get_baserel_parampathinfo(root, rel,
|
||||
required_outer);
|
||||
pathnode->path.parallel_aware = false;
|
||||
@ -1089,7 +1089,7 @@ create_bitmap_and_path(PlannerInfo *root,
|
||||
|
||||
pathnode->path.pathtype = T_BitmapAnd;
|
||||
pathnode->path.parent = rel;
|
||||
pathnode->path.pathtarget = &(rel->reltarget);
|
||||
pathnode->path.pathtarget = rel->reltarget;
|
||||
pathnode->path.param_info = NULL; /* not used in bitmap trees */
|
||||
|
||||
/*
|
||||
@ -1125,7 +1125,7 @@ create_bitmap_or_path(PlannerInfo *root,
|
||||
|
||||
pathnode->path.pathtype = T_BitmapOr;
|
||||
pathnode->path.parent = rel;
|
||||
pathnode->path.pathtarget = &(rel->reltarget);
|
||||
pathnode->path.pathtarget = rel->reltarget;
|
||||
pathnode->path.param_info = NULL; /* not used in bitmap trees */
|
||||
|
||||
/*
|
||||
@ -1160,7 +1160,7 @@ create_tidscan_path(PlannerInfo *root, RelOptInfo *rel, List *tidquals,
|
||||
|
||||
pathnode->path.pathtype = T_TidScan;
|
||||
pathnode->path.parent = rel;
|
||||
pathnode->path.pathtarget = &(rel->reltarget);
|
||||
pathnode->path.pathtarget = rel->reltarget;
|
||||
pathnode->path.param_info = get_baserel_parampathinfo(root, rel,
|
||||
required_outer);
|
||||
pathnode->path.parallel_aware = false;
|
||||
@ -1192,7 +1192,7 @@ create_append_path(RelOptInfo *rel, List *subpaths, Relids required_outer,
|
||||
|
||||
pathnode->path.pathtype = T_Append;
|
||||
pathnode->path.parent = rel;
|
||||
pathnode->path.pathtarget = &(rel->reltarget);
|
||||
pathnode->path.pathtarget = rel->reltarget;
|
||||
pathnode->path.param_info = get_appendrel_parampathinfo(rel,
|
||||
required_outer);
|
||||
pathnode->path.parallel_aware = false;
|
||||
@ -1251,7 +1251,7 @@ create_merge_append_path(PlannerInfo *root,
|
||||
|
||||
pathnode->path.pathtype = T_MergeAppend;
|
||||
pathnode->path.parent = rel;
|
||||
pathnode->path.pathtarget = &(rel->reltarget);
|
||||
pathnode->path.pathtarget = rel->reltarget;
|
||||
pathnode->path.param_info = get_appendrel_parampathinfo(rel,
|
||||
required_outer);
|
||||
pathnode->path.parallel_aware = false;
|
||||
@ -1375,7 +1375,7 @@ create_material_path(RelOptInfo *rel, Path *subpath)
|
||||
|
||||
pathnode->path.pathtype = T_Material;
|
||||
pathnode->path.parent = rel;
|
||||
pathnode->path.pathtarget = &(rel->reltarget);
|
||||
pathnode->path.pathtarget = rel->reltarget;
|
||||
pathnode->path.param_info = subpath->param_info;
|
||||
pathnode->path.parallel_aware = false;
|
||||
pathnode->path.parallel_safe = rel->consider_parallel &&
|
||||
@ -1440,7 +1440,7 @@ create_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath,
|
||||
|
||||
pathnode->path.pathtype = T_Unique;
|
||||
pathnode->path.parent = rel;
|
||||
pathnode->path.pathtarget = &(rel->reltarget);
|
||||
pathnode->path.pathtarget = rel->reltarget;
|
||||
pathnode->path.param_info = subpath->param_info;
|
||||
pathnode->path.parallel_aware = false;
|
||||
pathnode->path.parallel_safe = rel->consider_parallel &&
|
||||
@ -1656,7 +1656,7 @@ create_gather_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath,
|
||||
|
||||
pathnode->path.pathtype = T_Gather;
|
||||
pathnode->path.parent = rel;
|
||||
pathnode->path.pathtarget = &(rel->reltarget);
|
||||
pathnode->path.pathtarget = rel->reltarget;
|
||||
pathnode->path.param_info = get_baserel_parampathinfo(root, rel,
|
||||
required_outer);
|
||||
pathnode->path.parallel_aware = false;
|
||||
@ -1692,7 +1692,7 @@ create_subqueryscan_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath,
|
||||
|
||||
pathnode->path.pathtype = T_SubqueryScan;
|
||||
pathnode->path.parent = rel;
|
||||
pathnode->path.pathtarget = &(rel->reltarget);
|
||||
pathnode->path.pathtarget = rel->reltarget;
|
||||
pathnode->path.param_info = get_baserel_parampathinfo(root, rel,
|
||||
required_outer);
|
||||
pathnode->path.parallel_aware = false;
|
||||
@ -1720,7 +1720,7 @@ create_functionscan_path(PlannerInfo *root, RelOptInfo *rel,
|
||||
|
||||
pathnode->pathtype = T_FunctionScan;
|
||||
pathnode->parent = rel;
|
||||
pathnode->pathtarget = &(rel->reltarget);
|
||||
pathnode->pathtarget = rel->reltarget;
|
||||
pathnode->param_info = get_baserel_parampathinfo(root, rel,
|
||||
required_outer);
|
||||
pathnode->parallel_aware = false;
|
||||
@ -1746,7 +1746,7 @@ create_valuesscan_path(PlannerInfo *root, RelOptInfo *rel,
|
||||
|
||||
pathnode->pathtype = T_ValuesScan;
|
||||
pathnode->parent = rel;
|
||||
pathnode->pathtarget = &(rel->reltarget);
|
||||
pathnode->pathtarget = rel->reltarget;
|
||||
pathnode->param_info = get_baserel_parampathinfo(root, rel,
|
||||
required_outer);
|
||||
pathnode->parallel_aware = false;
|
||||
@ -1771,7 +1771,7 @@ create_ctescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer)
|
||||
|
||||
pathnode->pathtype = T_CteScan;
|
||||
pathnode->parent = rel;
|
||||
pathnode->pathtarget = &(rel->reltarget);
|
||||
pathnode->pathtarget = rel->reltarget;
|
||||
pathnode->param_info = get_baserel_parampathinfo(root, rel,
|
||||
required_outer);
|
||||
pathnode->parallel_aware = false;
|
||||
@ -1797,7 +1797,7 @@ create_worktablescan_path(PlannerInfo *root, RelOptInfo *rel,
|
||||
|
||||
pathnode->pathtype = T_WorkTableScan;
|
||||
pathnode->parent = rel;
|
||||
pathnode->pathtarget = &(rel->reltarget);
|
||||
pathnode->pathtarget = rel->reltarget;
|
||||
pathnode->param_info = get_baserel_parampathinfo(root, rel,
|
||||
required_outer);
|
||||
pathnode->parallel_aware = false;
|
||||
@ -1833,7 +1833,7 @@ create_foreignscan_path(PlannerInfo *root, RelOptInfo *rel,
|
||||
|
||||
pathnode->path.pathtype = T_ForeignScan;
|
||||
pathnode->path.parent = rel;
|
||||
pathnode->path.pathtarget = &(rel->reltarget);
|
||||
pathnode->path.pathtarget = rel->reltarget;
|
||||
pathnode->path.param_info = get_baserel_parampathinfo(root, rel,
|
||||
required_outer);
|
||||
pathnode->path.parallel_aware = false;
|
||||
@ -1966,7 +1966,7 @@ create_nestloop_path(PlannerInfo *root,
|
||||
|
||||
pathnode->path.pathtype = T_NestLoop;
|
||||
pathnode->path.parent = joinrel;
|
||||
pathnode->path.pathtarget = &(joinrel->reltarget);
|
||||
pathnode->path.pathtarget = joinrel->reltarget;
|
||||
pathnode->path.param_info =
|
||||
get_joinrel_parampathinfo(root,
|
||||
joinrel,
|
||||
@ -2029,7 +2029,7 @@ create_mergejoin_path(PlannerInfo *root,
|
||||
|
||||
pathnode->jpath.path.pathtype = T_MergeJoin;
|
||||
pathnode->jpath.path.parent = joinrel;
|
||||
pathnode->jpath.path.pathtarget = &(joinrel->reltarget);
|
||||
pathnode->jpath.path.pathtarget = joinrel->reltarget;
|
||||
pathnode->jpath.path.param_info =
|
||||
get_joinrel_parampathinfo(root,
|
||||
joinrel,
|
||||
@ -2091,7 +2091,7 @@ create_hashjoin_path(PlannerInfo *root,
|
||||
|
||||
pathnode->jpath.path.pathtype = T_HashJoin;
|
||||
pathnode->jpath.path.parent = joinrel;
|
||||
pathnode->jpath.path.pathtarget = &(joinrel->reltarget);
|
||||
pathnode->jpath.path.pathtarget = joinrel->reltarget;
|
||||
pathnode->jpath.path.param_info =
|
||||
get_joinrel_parampathinfo(root,
|
||||
joinrel,
|
||||
@ -2876,7 +2876,7 @@ create_modifytable_path(PlannerInfo *root, RelOptInfo *rel,
|
||||
pathnode->path.pathtype = T_ModifyTable;
|
||||
pathnode->path.parent = rel;
|
||||
/* pathtarget is not interesting, just make it minimally valid */
|
||||
pathnode->path.pathtarget = &(rel->reltarget);
|
||||
pathnode->path.pathtarget = rel->reltarget;
|
||||
/* For now, assume we are above any joins, so no parameterization */
|
||||
pathnode->path.param_info = NULL;
|
||||
pathnode->path.parallel_aware = false;
|
||||
|
@ -391,8 +391,8 @@ add_placeholders_to_base_rels(PlannerInfo *root)
|
||||
{
|
||||
RelOptInfo *rel = find_base_rel(root, varno);
|
||||
|
||||
rel->reltarget.exprs = lappend(rel->reltarget.exprs,
|
||||
copyObject(phinfo->ph_var));
|
||||
rel->reltarget->exprs = lappend(rel->reltarget->exprs,
|
||||
copyObject(phinfo->ph_var));
|
||||
/* reltarget's cost and width fields will be updated later */
|
||||
}
|
||||
}
|
||||
@ -425,9 +425,9 @@ add_placeholders_to_joinrel(PlannerInfo *root, RelOptInfo *joinrel,
|
||||
if (bms_is_subset(phinfo->ph_eval_at, relids))
|
||||
{
|
||||
/* Yup, add it to the output */
|
||||
joinrel->reltarget.exprs = lappend(joinrel->reltarget.exprs,
|
||||
phinfo->ph_var);
|
||||
joinrel->reltarget.width += phinfo->ph_width;
|
||||
joinrel->reltarget->exprs = lappend(joinrel->reltarget->exprs,
|
||||
phinfo->ph_var);
|
||||
joinrel->reltarget->width += phinfo->ph_width;
|
||||
|
||||
/*
|
||||
* Charge the cost of evaluating the contained expression if
|
||||
@ -447,8 +447,8 @@ add_placeholders_to_joinrel(PlannerInfo *root, RelOptInfo *joinrel,
|
||||
|
||||
cost_qual_eval_node(&cost, (Node *) phinfo->ph_var->phexpr,
|
||||
root);
|
||||
joinrel->reltarget.cost.startup += cost.startup;
|
||||
joinrel->reltarget.cost.per_tuple += cost.per_tuple;
|
||||
joinrel->reltarget->cost.startup += cost.startup;
|
||||
joinrel->reltarget->cost.per_tuple += cost.per_tuple;
|
||||
}
|
||||
|
||||
/* Adjust joinrel's direct_lateral_relids as needed */
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "optimizer/placeholder.h"
|
||||
#include "optimizer/plancat.h"
|
||||
#include "optimizer/restrictinfo.h"
|
||||
#include "optimizer/tlist.h"
|
||||
#include "utils/hsearch.h"
|
||||
|
||||
|
||||
@ -106,11 +107,7 @@ build_simple_rel(PlannerInfo *root, int relid, RelOptKind reloptkind)
|
||||
rel->consider_startup = (root->tuple_fraction > 0);
|
||||
rel->consider_param_startup = false; /* might get changed later */
|
||||
rel->consider_parallel = false; /* might get changed later */
|
||||
rel->reltarget.exprs = NIL;
|
||||
rel->reltarget.sortgrouprefs = NULL;
|
||||
rel->reltarget.cost.startup = 0;
|
||||
rel->reltarget.cost.per_tuple = 0;
|
||||
rel->reltarget.width = 0;
|
||||
rel->reltarget = create_empty_pathtarget();
|
||||
rel->pathlist = NIL;
|
||||
rel->ppilist = NIL;
|
||||
rel->partial_pathlist = NIL;
|
||||
@ -393,11 +390,7 @@ build_join_rel(PlannerInfo *root,
|
||||
joinrel->consider_startup = (root->tuple_fraction > 0);
|
||||
joinrel->consider_param_startup = false;
|
||||
joinrel->consider_parallel = false;
|
||||
joinrel->reltarget.exprs = NIL;
|
||||
joinrel->reltarget.sortgrouprefs = NULL;
|
||||
joinrel->reltarget.cost.startup = 0;
|
||||
joinrel->reltarget.cost.per_tuple = 0;
|
||||
joinrel->reltarget.width = 0;
|
||||
joinrel->reltarget = create_empty_pathtarget();
|
||||
joinrel->pathlist = NIL;
|
||||
joinrel->ppilist = NIL;
|
||||
joinrel->partial_pathlist = NIL;
|
||||
@ -613,7 +606,7 @@ build_joinrel_tlist(PlannerInfo *root, RelOptInfo *joinrel,
|
||||
Relids relids = joinrel->relids;
|
||||
ListCell *vars;
|
||||
|
||||
foreach(vars, input_rel->reltarget.exprs)
|
||||
foreach(vars, input_rel->reltarget->exprs)
|
||||
{
|
||||
Var *var = (Var *) lfirst(vars);
|
||||
RelOptInfo *baserel;
|
||||
@ -643,9 +636,9 @@ build_joinrel_tlist(PlannerInfo *root, RelOptInfo *joinrel,
|
||||
if (bms_nonempty_difference(baserel->attr_needed[ndx], relids))
|
||||
{
|
||||
/* Yup, add it to the output */
|
||||
joinrel->reltarget.exprs = lappend(joinrel->reltarget.exprs, var);
|
||||
/* Vars have cost zero, so no need to adjust reltarget.cost */
|
||||
joinrel->reltarget.width += baserel->attr_widths[ndx];
|
||||
joinrel->reltarget->exprs = lappend(joinrel->reltarget->exprs, var);
|
||||
/* Vars have cost zero, so no need to adjust reltarget->cost */
|
||||
joinrel->reltarget->width += baserel->attr_widths[ndx];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -832,6 +825,7 @@ build_empty_join_rel(PlannerInfo *root)
|
||||
joinrel->relids = NULL; /* empty set */
|
||||
joinrel->rows = 1; /* we produce one row for such cases */
|
||||
joinrel->rtekind = RTE_JOIN;
|
||||
joinrel->reltarget = create_empty_pathtarget();
|
||||
|
||||
root->join_rel_list = lappend(root->join_rel_list, joinrel);
|
||||
|
||||
@ -882,6 +876,7 @@ fetch_upper_rel(PlannerInfo *root, UpperRelationKind kind, Relids relids)
|
||||
upperrel->consider_startup = (root->tuple_fraction > 0);
|
||||
upperrel->consider_param_startup = false;
|
||||
upperrel->consider_parallel = false; /* might get changed later */
|
||||
upperrel->reltarget = create_empty_pathtarget();
|
||||
upperrel->pathlist = NIL;
|
||||
upperrel->cheapest_startup_path = NULL;
|
||||
upperrel->cheapest_total_path = NULL;
|
||||
|
@ -546,7 +546,7 @@ grouping_is_hashable(List *groupClause)
|
||||
PathTarget *
|
||||
make_pathtarget_from_tlist(List *tlist)
|
||||
{
|
||||
PathTarget *target = (PathTarget *) palloc0(sizeof(PathTarget));
|
||||
PathTarget *target = makeNode(PathTarget);
|
||||
int i;
|
||||
ListCell *lc;
|
||||
|
||||
@ -606,7 +606,7 @@ make_tlist_from_pathtarget(PathTarget *target)
|
||||
PathTarget *
|
||||
copy_pathtarget(PathTarget *src)
|
||||
{
|
||||
PathTarget *dst = (PathTarget *) palloc(sizeof(PathTarget));
|
||||
PathTarget *dst = makeNode(PathTarget);
|
||||
|
||||
/* Copy scalar fields */
|
||||
memcpy(dst, src, sizeof(PathTarget));
|
||||
@ -631,7 +631,7 @@ PathTarget *
|
||||
create_empty_pathtarget(void)
|
||||
{
|
||||
/* This is easy, but we don't want callers to hard-wire this ... */
|
||||
return (PathTarget *) palloc0(sizeof(PathTarget));
|
||||
return makeNode(PathTarget);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user