diff options
Diffstat (limited to 'src/backend/optimizer/util/pathnode.c')
-rw-r--r-- | src/backend/optimizer/util/pathnode.c | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index 1097a1804a6..9417587abff 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -929,6 +929,7 @@ create_seqscan_path(PlannerInfo *root, RelOptInfo *rel, pathnode->pathtype = T_SeqScan; pathnode->parent = rel; + pathnode->pathtarget = &(rel->reltarget); pathnode->param_info = get_baserel_parampathinfo(root, rel, required_outer); pathnode->parallel_aware = parallel_degree > 0 ? true : false; @@ -952,6 +953,7 @@ create_samplescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer pathnode->pathtype = T_SampleScan; pathnode->parent = rel; + pathnode->pathtarget = &(rel->reltarget); pathnode->param_info = get_baserel_parampathinfo(root, rel, required_outer); pathnode->parallel_aware = false; @@ -1008,6 +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.param_info = get_baserel_parampathinfo(root, rel, required_outer); pathnode->path.parallel_aware = false; @@ -1056,6 +1059,7 @@ create_bitmap_heap_path(PlannerInfo *root, pathnode->path.pathtype = T_BitmapHeapScan; pathnode->path.parent = rel; + pathnode->path.pathtarget = &(rel->reltarget); pathnode->path.param_info = get_baserel_parampathinfo(root, rel, required_outer); pathnode->path.parallel_aware = false; @@ -1085,6 +1089,7 @@ create_bitmap_and_path(PlannerInfo *root, pathnode->path.pathtype = T_BitmapAnd; pathnode->path.parent = rel; + pathnode->path.pathtarget = &(rel->reltarget); pathnode->path.param_info = NULL; /* not used in bitmap trees */ /* @@ -1120,6 +1125,7 @@ create_bitmap_or_path(PlannerInfo *root, pathnode->path.pathtype = T_BitmapOr; pathnode->path.parent = rel; + pathnode->path.pathtarget = &(rel->reltarget); pathnode->path.param_info = NULL; /* not used in bitmap trees */ /* @@ -1154,6 +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.param_info = get_baserel_parampathinfo(root, rel, required_outer); pathnode->path.parallel_aware = false; @@ -1185,6 +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.param_info = get_appendrel_parampathinfo(rel, required_outer); pathnode->path.parallel_aware = false; @@ -1243,6 +1251,7 @@ create_merge_append_path(PlannerInfo *root, pathnode->path.pathtype = T_MergeAppend; pathnode->path.parent = rel; + pathnode->path.pathtarget = &(rel->reltarget); pathnode->path.param_info = get_appendrel_parampathinfo(rel, required_outer); pathnode->path.parallel_aware = false; @@ -1290,7 +1299,7 @@ create_merge_append_path(PlannerInfo *root, pathkeys, subpath->total_cost, subpath->parent->tuples, - subpath->parent->width, + subpath->pathtarget->width, 0.0, work_mem, pathnode->limit_tuples); @@ -1322,7 +1331,8 @@ create_result_path(RelOptInfo *rel, List *quals) ResultPath *pathnode = makeNode(ResultPath); pathnode->path.pathtype = T_Result; - pathnode->path.parent = NULL; + pathnode->path.parent = rel; + pathnode->path.pathtarget = &(rel->reltarget); pathnode->path.param_info = NULL; /* there are no other rels... */ pathnode->path.parallel_aware = false; pathnode->path.parallel_safe = rel->consider_parallel; @@ -1339,7 +1349,10 @@ create_result_path(RelOptInfo *rel, List *quals) * In theory we should include the qual eval cost as well, but at present * that doesn't accomplish much except duplicate work that will be done * again in make_result; since this is only used for degenerate cases, - * nothing interesting will be done with the path cost values... + * nothing interesting will be done with the path cost values. + * + * (Likewise, we don't worry about pathtarget->cost since that tlist will + * be empty at this point.) */ return pathnode; @@ -1359,6 +1372,7 @@ create_material_path(RelOptInfo *rel, Path *subpath) pathnode->path.pathtype = T_Material; pathnode->path.parent = rel; + pathnode->path.pathtarget = &(rel->reltarget); pathnode->path.param_info = subpath->param_info; pathnode->path.parallel_aware = false; pathnode->path.parallel_safe = subpath->parallel_safe; @@ -1371,7 +1385,7 @@ create_material_path(RelOptInfo *rel, Path *subpath) subpath->startup_cost, subpath->total_cost, subpath->rows, - rel->width); + subpath->pathtarget->width); return pathnode; } @@ -1422,6 +1436,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.param_info = subpath->param_info; pathnode->path.parallel_aware = false; pathnode->path.parallel_safe = subpath->parallel_safe; @@ -1516,7 +1531,7 @@ create_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, cost_sort(&sort_path, root, NIL, subpath->total_cost, rel->rows, - rel->width, + subpath->pathtarget->width, 0.0, work_mem, -1.0); @@ -1536,7 +1551,7 @@ create_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, * Estimate the overhead per hashtable entry at 64 bytes (same as in * planner.c). */ - int hashentrysize = rel->width + 64; + int hashentrysize = subpath->pathtarget->width + 64; if (hashentrysize * pathnode->path.rows > work_mem * 1024L) { @@ -1607,6 +1622,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.param_info = get_baserel_parampathinfo(root, rel, required_outer); pathnode->path.parallel_aware = false; @@ -1672,6 +1688,7 @@ create_subqueryscan_path(PlannerInfo *root, RelOptInfo *rel, pathnode->pathtype = T_SubqueryScan; pathnode->parent = rel; + pathnode->pathtarget = &(rel->reltarget); pathnode->param_info = get_baserel_parampathinfo(root, rel, required_outer); pathnode->parallel_aware = false; @@ -1697,6 +1714,7 @@ create_functionscan_path(PlannerInfo *root, RelOptInfo *rel, pathnode->pathtype = T_FunctionScan; pathnode->parent = rel; + pathnode->pathtarget = &(rel->reltarget); pathnode->param_info = get_baserel_parampathinfo(root, rel, required_outer); pathnode->parallel_aware = false; @@ -1722,6 +1740,7 @@ create_valuesscan_path(PlannerInfo *root, RelOptInfo *rel, pathnode->pathtype = T_ValuesScan; pathnode->parent = rel; + pathnode->pathtarget = &(rel->reltarget); pathnode->param_info = get_baserel_parampathinfo(root, rel, required_outer); pathnode->parallel_aware = false; @@ -1746,6 +1765,7 @@ create_ctescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer) pathnode->pathtype = T_CteScan; pathnode->parent = rel; + pathnode->pathtarget = &(rel->reltarget); pathnode->param_info = get_baserel_parampathinfo(root, rel, required_outer); pathnode->parallel_aware = false; @@ -1771,6 +1791,7 @@ create_worktablescan_path(PlannerInfo *root, RelOptInfo *rel, pathnode->pathtype = T_WorkTableScan; pathnode->parent = rel; + pathnode->pathtarget = &(rel->reltarget); pathnode->param_info = get_baserel_parampathinfo(root, rel, required_outer); pathnode->parallel_aware = false; @@ -1806,6 +1827,7 @@ create_foreignscan_path(PlannerInfo *root, RelOptInfo *rel, pathnode->path.pathtype = T_ForeignScan; pathnode->path.parent = rel; + pathnode->path.pathtarget = &(rel->reltarget); pathnode->path.param_info = get_baserel_parampathinfo(root, rel, required_outer); pathnode->path.parallel_aware = false; @@ -1938,6 +1960,7 @@ create_nestloop_path(PlannerInfo *root, pathnode->path.pathtype = T_NestLoop; pathnode->path.parent = joinrel; + pathnode->path.pathtarget = &(joinrel->reltarget); pathnode->path.param_info = get_joinrel_parampathinfo(root, joinrel, @@ -2000,6 +2023,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.param_info = get_joinrel_parampathinfo(root, joinrel, @@ -2060,6 +2084,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.param_info = get_joinrel_parampathinfo(root, joinrel, |