From 0d42c1c80282d9f92f03e6684cf8e6a060e02fed Mon Sep 17 00:00:00 2001 From: Anthonin Bonnefoy Date: Mon, 15 Jul 2024 06:43:36 +0200 Subject: Propagate root PlannerInfo to add_path --- contrib/file_fdw/file_fdw.c | 2 +- contrib/postgres_fdw/postgres_fdw.c | 18 ++-- src/backend/optimizer/path/allpaths.c | 144 ++++++++++++------------- src/backend/optimizer/path/indxpath.c | 6 +- src/backend/optimizer/path/joinpath.c | 6 +- src/backend/optimizer/path/joinrels.c | 24 ++--- src/backend/optimizer/path/tidpath.c | 12 +-- src/backend/optimizer/plan/planagg.c | 2 +- src/backend/optimizer/plan/planmain.c | 2 +- src/backend/optimizer/plan/planner.c | 42 ++++---- src/backend/optimizer/prep/prepunion.c | 42 ++++---- src/backend/optimizer/util/pathnode.c | 2 +- src/backend/optimizer/util/relnode.c | 2 +- src/include/optimizer/pathnode.h | 2 +- src/include/optimizer/paths.h | 2 +- 15 files changed, 154 insertions(+), 154 deletions(-) diff --git a/contrib/file_fdw/file_fdw.c b/contrib/file_fdw/file_fdw.c index 249d82d3a05..5d1d8faf31b 100644 --- a/contrib/file_fdw/file_fdw.c +++ b/contrib/file_fdw/file_fdw.c @@ -572,7 +572,7 @@ fileGetForeignPaths(PlannerInfo *root, * it could still have required parameterization due to LATERAL refs in * its tlist. */ - add_path(baserel, (Path *) + add_path(root, baserel, (Path *) create_foreignscan_path(root, baserel, NULL, /* default pathtarget */ baserel->rows, diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c index fc65d81e217..47a3ebc4e0b 100644 --- a/contrib/postgres_fdw/postgres_fdw.c +++ b/contrib/postgres_fdw/postgres_fdw.c @@ -1037,7 +1037,7 @@ postgresGetForeignPaths(PlannerInfo *root, NULL, /* no extra plan */ NIL, /* no fdw_restrictinfo list */ NIL); /* no fdw_private list */ - add_path(baserel, (Path *) path); + add_path(root, baserel, (Path *) path); /* Add paths with pathkeys */ add_paths_with_pathkeys_for_rel(root, baserel, NULL, NIL); @@ -1210,7 +1210,7 @@ postgresGetForeignPaths(PlannerInfo *root, NULL, NIL, /* no fdw_restrictinfo list */ NIL); /* no fdw_private list */ - add_path(baserel, (Path *) path); + add_path(root, baserel, (Path *) path); } } @@ -6171,7 +6171,7 @@ add_paths_with_pathkeys_for_rel(PlannerInfo *root, RelOptInfo *rel, -1.0); if (IS_SIMPLE_REL(rel)) - add_path(rel, (Path *) + add_path(root, rel, (Path *) create_foreignscan_path(root, rel, NULL, rows, @@ -6184,7 +6184,7 @@ add_paths_with_pathkeys_for_rel(PlannerInfo *root, RelOptInfo *rel, * list */ NIL)); else - add_path(rel, (Path *) + add_path(root, rel, (Path *) create_foreign_join_path(root, rel, NULL, rows, @@ -6450,7 +6450,7 @@ postgresGetForeignJoinPaths(PlannerInfo *root, NIL); /* no fdw_private */ /* Add generated path into joinrel by add_path(). */ - add_path(joinrel, (Path *) joinpath); + add_path(root, joinrel, (Path *) joinpath); /* Consider pathkeys for the join relation */ add_paths_with_pathkeys_for_rel(root, joinrel, epq_path, @@ -6839,7 +6839,7 @@ add_foreign_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel, NIL); /* no fdw_private */ /* Add generated path into grouped_rel by add_path(). */ - add_path(grouped_rel, (Path *) grouppath); + add_path(root, grouped_rel, (Path *) grouppath); } /* @@ -6974,7 +6974,7 @@ add_foreign_ordered_paths(PlannerInfo *root, RelOptInfo *input_rel, fdw_private); /* and add it to the ordered_rel */ - add_path(ordered_rel, (Path *) ordered_path); + add_path(root, ordered_rel, (Path *) ordered_path); } /* @@ -7091,7 +7091,7 @@ add_foreign_final_paths(PlannerInfo *root, RelOptInfo *input_rel, NIL); /* no fdw_private */ /* and add it to the final_rel */ - add_path(final_rel, (Path *) final_path); + add_path(root, final_rel, (Path *) final_path); /* Safe to push down */ fpinfo->pushdown_safe = true; @@ -7226,7 +7226,7 @@ add_foreign_final_paths(PlannerInfo *root, RelOptInfo *input_rel, fdw_private); /* and add it to the final_rel */ - add_path(final_rel, (Path *) final_path); + add_path(root, final_rel, (Path *) final_path); } /* diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index 057b4b79ebb..dff4eb6491b 100644 --- a/src/backend/optimizer/path/allpaths.c +++ b/src/backend/optimizer/path/allpaths.c @@ -124,7 +124,7 @@ static void accumulate_append_subpath(Path *path, List **subpaths, List **special_subpaths); static Path *get_singleton_append_subpath(Path *path); -static void set_dummy_rel_pathlist(RelOptInfo *rel); +static void set_dummy_rel_pathlist(PlannerInfo *root, RelOptInfo *rel); static void set_subquery_pathlist(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTblEntry *rte); static void set_function_pathlist(PlannerInfo *root, RelOptInfo *rel, @@ -374,7 +374,7 @@ set_rel_size(PlannerInfo *root, RelOptInfo *rel, * we don't have a convention for marking a rel as dummy except by * assigning a dummy path to it. */ - set_dummy_rel_pathlist(rel); + set_dummy_rel_pathlist(root, rel); } else if (rte->inh) { @@ -398,7 +398,7 @@ set_rel_size(PlannerInfo *root, RelOptInfo *rel, * with ONLY. In that case we shouldn't scan any of the * partitions, so mark it as a dummy rel. */ - set_dummy_rel_pathlist(rel); + set_dummy_rel_pathlist(root, rel); } else if (rte->tablesample != NULL) { @@ -784,7 +784,7 @@ set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte) return; /* Consider sequential scan */ - add_path(rel, create_seqscan_path(root, rel, required_outer, 0)); + add_path(root, rel, create_seqscan_path(root, rel, required_outer, 0)); /* If appropriate, consider parallel sequential scan */ if (rel->consider_parallel && required_outer == NULL) @@ -897,7 +897,7 @@ set_tablesample_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry * path = (Path *) create_material_path(rel, path); } - add_path(rel, path); + add_path(root, rel, path); /* For the moment, at least, there are no other paths to consider */ } @@ -1038,7 +1038,7 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel, * This child need not be scanned, so we can omit it from the * appendrel. */ - set_dummy_rel_pathlist(childrel); + set_dummy_rel_pathlist(root, childrel); continue; } @@ -1226,7 +1226,7 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel, * appendrel dummy. We must do this in this phase so that the rel's * dummy-ness is visible when we generate paths for other rels. */ - set_dummy_rel_pathlist(rel); + set_dummy_rel_pathlist(root, rel); } pfree(parent_attrsizes); @@ -1498,14 +1498,14 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel, * if we have zero or one live subpath due to constraint exclusion.) */ if (subpaths_valid) - add_path(rel, (Path *) create_append_path(root, rel, subpaths, NIL, - NIL, NULL, 0, false, - -1)); + add_path(root, rel, (Path *) create_append_path(root, rel, subpaths, NIL, + NIL, NULL, 0, false, + -1)); /* build an AppendPath for the cheap startup paths, if valid */ if (startup_subpaths_valid) - add_path(rel, (Path *) create_append_path(root, rel, startup_subpaths, - NIL, NIL, NULL, 0, false, -1)); + add_path(root, rel, (Path *) create_append_path(root, rel, startup_subpaths, + NIL, NIL, NULL, 0, false, -1)); /* * Consider an append of unordered, unparameterized partial paths. Make @@ -1655,7 +1655,7 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel, } if (subpaths_valid) - add_path(rel, (Path *) + add_path(root, rel, (Path *) create_append_path(root, rel, subpaths, NIL, NIL, required_outer, 0, false, -1)); @@ -1940,58 +1940,58 @@ generate_orderedappend_paths(PlannerInfo *root, RelOptInfo *rel, if (match_partition_order) { /* We only need Append */ - add_path(rel, (Path *) create_append_path(root, - rel, - startup_subpaths, - NIL, - pathkeys, - NULL, - 0, - false, - -1)); - if (startup_neq_total) - add_path(rel, (Path *) create_append_path(root, - rel, - total_subpaths, - NIL, - pathkeys, - NULL, - 0, - false, - -1)); - - if (fractional_subpaths) - add_path(rel, (Path *) create_append_path(root, - rel, - fractional_subpaths, - NIL, - pathkeys, - NULL, - 0, - false, - -1)); - } - else - { - /* We need MergeAppend */ - add_path(rel, (Path *) create_merge_append_path(root, + add_path(root, rel, (Path *) create_append_path(root, rel, startup_subpaths, + NIL, pathkeys, - NULL)); + NULL, + 0, + false, + -1)); if (startup_neq_total) - add_path(rel, (Path *) create_merge_append_path(root, + add_path(root, rel, (Path *) create_append_path(root, rel, total_subpaths, + NIL, pathkeys, - NULL)); + NULL, + 0, + false, + -1)); if (fractional_subpaths) - add_path(rel, (Path *) create_merge_append_path(root, + add_path(root, rel, (Path *) create_append_path(root, rel, fractional_subpaths, + NIL, pathkeys, - NULL)); + NULL, + 0, + false, + -1)); + } + else + { + /* We need MergeAppend */ + add_path(root, rel, (Path *) create_merge_append_path(root, + rel, + startup_subpaths, + pathkeys, + NULL)); + if (startup_neq_total) + add_path(root, rel, (Path *) create_merge_append_path(root, + rel, + total_subpaths, + pathkeys, + NULL)); + + if (fractional_subpaths) + add_path(root, rel, (Path *) create_merge_append_path(root, + rel, + fractional_subpaths, + pathkeys, + NULL)); } } } @@ -2171,7 +2171,7 @@ get_singleton_append_subpath(Path *path) * paths for it.) */ static void -set_dummy_rel_pathlist(RelOptInfo *rel) +set_dummy_rel_pathlist(PlannerInfo *root, RelOptInfo *rel) { /* Set dummy size estimates --- we leave attr_widths[] as zeroes */ rel->rows = 0; @@ -2182,9 +2182,9 @@ set_dummy_rel_pathlist(RelOptInfo *rel) rel->partial_pathlist = NIL; /* Set up the dummy path */ - add_path(rel, (Path *) create_append_path(NULL, rel, NIL, NIL, - NIL, rel->lateral_relids, - 0, false, -1)); + add_path(root, rel, (Path *) create_append_path(NULL, rel, NIL, NIL, + NIL, rel->lateral_relids, + 0, false, -1)); /* * We set the cheapest-path fields immediately, just in case they were @@ -2657,7 +2657,7 @@ set_subquery_pathlist(PlannerInfo *root, RelOptInfo *rel, if (IS_DUMMY_REL(sub_final_rel)) { - set_dummy_rel_pathlist(rel); + set_dummy_rel_pathlist(root, rel); return; } @@ -2714,7 +2714,7 @@ set_subquery_pathlist(PlannerInfo *root, RelOptInfo *rel, make_tlist_from_pathtarget(subpath->pathtarget)); /* Generate outer path using this subpath */ - add_path(rel, (Path *) + add_path(root, rel, (Path *) create_subqueryscan_path(root, rel, subpath, trivial_pathtarget, pathkeys, required_outer)); @@ -2812,8 +2812,8 @@ set_function_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte) } /* Generate appropriate path */ - add_path(rel, create_functionscan_path(root, rel, - pathkeys, required_outer)); + add_path(root, rel, create_functionscan_path(root, rel, + pathkeys, required_outer)); } /* @@ -2833,7 +2833,7 @@ set_values_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte) required_outer = rel->lateral_relids; /* Generate appropriate path */ - add_path(rel, create_valuesscan_path(root, rel, required_outer)); + add_path(root, rel, create_valuesscan_path(root, rel, required_outer)); } /* @@ -2853,8 +2853,8 @@ set_tablefunc_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte) required_outer = rel->lateral_relids; /* Generate appropriate path */ - add_path(rel, create_tablefuncscan_path(root, rel, - required_outer)); + add_path(root, rel, create_tablefuncscan_path(root, rel, + required_outer)); } /* @@ -2933,7 +2933,7 @@ set_cte_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte) required_outer = rel->lateral_relids; /* Generate appropriate path */ - add_path(rel, create_ctescan_path(root, rel, pathkeys, required_outer)); + add_path(root, rel, create_ctescan_path(root, rel, pathkeys, required_outer)); } /* @@ -2960,7 +2960,7 @@ set_namedtuplestore_pathlist(PlannerInfo *root, RelOptInfo *rel, required_outer = rel->lateral_relids; /* Generate appropriate path */ - add_path(rel, create_namedtuplestorescan_path(root, rel, required_outer)); + add_path(root, rel, create_namedtuplestorescan_path(root, rel, required_outer)); } /* @@ -2987,7 +2987,7 @@ set_result_pathlist(PlannerInfo *root, RelOptInfo *rel, required_outer = rel->lateral_relids; /* Generate appropriate path */ - add_path(rel, create_resultscan_path(root, rel, required_outer)); + add_path(root, rel, create_resultscan_path(root, rel, required_outer)); } /* @@ -3037,7 +3037,7 @@ set_worktable_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte) required_outer = rel->lateral_relids; /* Generate appropriate path */ - add_path(rel, create_worktablescan_path(root, rel, required_outer)); + add_path(root, rel, create_worktablescan_path(root, rel, required_outer)); } /* @@ -3083,7 +3083,7 @@ generate_gather_paths(PlannerInfo *root, RelOptInfo *rel, bool override_rows) simple_gather_path = (Path *) create_gather_path(root, rel, cheapest_partial_path, rel->reltarget, NULL, rowsp); - add_path(rel, simple_gather_path); + add_path(root, rel, simple_gather_path); /* * For each useful ordering, we can consider an order-preserving Gather @@ -3100,7 +3100,7 @@ generate_gather_paths(PlannerInfo *root, RelOptInfo *rel, bool override_rows) rows = compute_gather_rows(subpath); path = create_gather_merge_path(root, rel, subpath, rel->reltarget, subpath->pathkeys, NULL, rowsp); - add_path(rel, &path->path); + add_path(root, rel, &path->path); } } @@ -3297,7 +3297,7 @@ generate_useful_gather_paths(PlannerInfo *root, RelOptInfo *rel, bool override_r NULL, rowsp); - add_path(rel, &path->path); + add_path(root, rel, &path->path); } } } @@ -4359,7 +4359,7 @@ generate_partitionwise_join_paths(PlannerInfo *root, RelOptInfo *rel) /* If all child-joins are dummy, parent join is also dummy. */ if (!live_children) { - mark_dummy_rel(rel); + mark_dummy_rel(root, rel); return; } diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c index c0fcc7d78df..ac74217636a 100644 --- a/src/backend/optimizer/path/indxpath.c +++ b/src/backend/optimizer/path/indxpath.c @@ -340,7 +340,7 @@ create_index_paths(PlannerInfo *root, RelOptInfo *rel) bitmapqual = choose_bitmap_and(root, rel, bitindexpaths); bpath = create_bitmap_heap_path(root, rel, bitmapqual, rel->lateral_relids, 1.0, 0); - add_path(rel, (Path *) bpath); + add_path(root, rel, (Path *) bpath); /* create a partial bitmap heap path */ if (rel->consider_parallel && rel->lateral_relids == NULL) @@ -407,7 +407,7 @@ create_index_paths(PlannerInfo *root, RelOptInfo *rel) loop_count = get_loop_count(root, rel->relid, required_outer); bpath = create_bitmap_heap_path(root, rel, bitmapqual, required_outer, loop_count, 0); - add_path(rel, (Path *) bpath); + add_path(root, rel, (Path *) bpath); } } } @@ -742,7 +742,7 @@ get_index_paths(PlannerInfo *root, RelOptInfo *rel, IndexPath *ipath = (IndexPath *) lfirst(lc); if (index->amhasgettuple) - add_path(rel, (Path *) ipath); + add_path(root, rel, (Path *) ipath); if (index->amhasgetbitmap && (ipath->path.pathkeys == NIL || diff --git a/src/backend/optimizer/path/joinpath.c b/src/backend/optimizer/path/joinpath.c index 7a2c20b1450..e92b8359470 100644 --- a/src/backend/optimizer/path/joinpath.c +++ b/src/backend/optimizer/path/joinpath.c @@ -919,7 +919,7 @@ try_nestloop_path(PlannerInfo *root, workspace.startup_cost, workspace.total_cost, pathkeys, required_outer)) { - add_path(joinrel, (Path *) + add_path(root, joinrel, (Path *) create_nestloop_path(root, joinrel, jointype, @@ -1099,7 +1099,7 @@ try_mergejoin_path(PlannerInfo *root, workspace.startup_cost, workspace.total_cost, pathkeys, required_outer)) { - add_path(joinrel, (Path *) + add_path(root, joinrel, (Path *) create_mergejoin_path(root, joinrel, jointype, @@ -1244,7 +1244,7 @@ try_hashjoin_path(PlannerInfo *root, workspace.startup_cost, workspace.total_cost, NIL, required_outer)) { - add_path(joinrel, (Path *) + add_path(root, joinrel, (Path *) create_hashjoin_path(root, joinrel, jointype, diff --git a/src/backend/optimizer/path/joinrels.c b/src/backend/optimizer/path/joinrels.c index a3677f824fe..a5f3b7996ae 100644 --- a/src/backend/optimizer/path/joinrels.c +++ b/src/backend/optimizer/path/joinrels.c @@ -918,7 +918,7 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1, if (is_dummy_rel(rel1) || is_dummy_rel(rel2) || restriction_is_constant_false(restrictlist, joinrel, false)) { - mark_dummy_rel(joinrel); + mark_dummy_rel(root, joinrel); break; } add_paths_to_joinrel(root, joinrel, rel1, rel2, @@ -932,12 +932,12 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1, if (is_dummy_rel(rel1) || restriction_is_constant_false(restrictlist, joinrel, true)) { - mark_dummy_rel(joinrel); + mark_dummy_rel(root, joinrel); break; } if (restriction_is_constant_false(restrictlist, joinrel, false) && bms_is_subset(rel2->relids, sjinfo->syn_righthand)) - mark_dummy_rel(rel2); + mark_dummy_rel(root, rel2); add_paths_to_joinrel(root, joinrel, rel1, rel2, JOIN_LEFT, sjinfo, restrictlist); @@ -949,7 +949,7 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1, if ((is_dummy_rel(rel1) && is_dummy_rel(rel2)) || restriction_is_constant_false(restrictlist, joinrel, true)) { - mark_dummy_rel(joinrel); + mark_dummy_rel(root, joinrel); break; } add_paths_to_joinrel(root, joinrel, rel1, rel2, @@ -985,7 +985,7 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1, if (is_dummy_rel(rel1) || is_dummy_rel(rel2) || restriction_is_constant_false(restrictlist, joinrel, false)) { - mark_dummy_rel(joinrel); + mark_dummy_rel(root, joinrel); break; } add_paths_to_joinrel(root, joinrel, rel1, rel2, @@ -1011,7 +1011,7 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1, if (is_dummy_rel(rel1) || is_dummy_rel(rel2) || restriction_is_constant_false(restrictlist, joinrel, false)) { - mark_dummy_rel(joinrel); + mark_dummy_rel(root, joinrel); break; } add_paths_to_joinrel(root, joinrel, rel1, rel2, @@ -1026,12 +1026,12 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1, if (is_dummy_rel(rel1) || restriction_is_constant_false(restrictlist, joinrel, true)) { - mark_dummy_rel(joinrel); + mark_dummy_rel(root, joinrel); break; } if (restriction_is_constant_false(restrictlist, joinrel, false) && bms_is_subset(rel2->relids, sjinfo->syn_righthand)) - mark_dummy_rel(rel2); + mark_dummy_rel(root, rel2); add_paths_to_joinrel(root, joinrel, rel1, rel2, JOIN_ANTI, sjinfo, restrictlist); @@ -1381,7 +1381,7 @@ is_dummy_rel(RelOptInfo *rel) * context the given RelOptInfo is in. */ void -mark_dummy_rel(RelOptInfo *rel) +mark_dummy_rel(PlannerInfo *root, RelOptInfo *rel) { MemoryContext oldcontext; @@ -1400,9 +1400,9 @@ mark_dummy_rel(RelOptInfo *rel) rel->partial_pathlist = NIL; /* Set up the dummy path */ - add_path(rel, (Path *) create_append_path(NULL, rel, NIL, NIL, - NIL, rel->lateral_relids, - 0, false, -1)); + add_path(root, rel, (Path *) create_append_path(NULL, rel, NIL, NIL, + NIL, rel->lateral_relids, + 0, false, -1)); /* Set or update cheapest_total_path and related fields */ set_cheapest(rel); diff --git a/src/backend/optimizer/path/tidpath.c b/src/backend/optimizer/path/tidpath.c index b0323b26eca..2e4094599eb 100644 --- a/src/backend/optimizer/path/tidpath.c +++ b/src/backend/optimizer/path/tidpath.c @@ -467,8 +467,8 @@ BuildParameterizedTidPaths(PlannerInfo *root, RelOptInfo *rel, List *clauses) required_outer = bms_union(rinfo->required_relids, rel->lateral_relids); required_outer = bms_del_member(required_outer, rel->relid); - add_path(rel, (Path *) create_tidscan_path(root, rel, tidquals, - required_outer)); + add_path(root, rel, (Path *) create_tidscan_path(root, rel, tidquals, + required_outer)); } } @@ -519,7 +519,7 @@ create_tidscan_paths(PlannerInfo *root, RelOptInfo *rel) */ Relids required_outer = rel->lateral_relids; - add_path(rel, (Path *) create_tidscan_path(root, rel, tidquals, + add_path(root, rel, (Path *) create_tidscan_path(root, rel, tidquals, required_outer)); /* @@ -551,9 +551,9 @@ create_tidscan_paths(PlannerInfo *root, RelOptInfo *rel) */ Relids required_outer = rel->lateral_relids; - add_path(rel, (Path *) create_tidrangescan_path(root, rel, - tidrangequals, - required_outer)); + add_path(root, rel, (Path *) create_tidrangescan_path(root, rel, + tidrangequals, + required_outer)); } /* diff --git a/src/backend/optimizer/plan/planagg.c b/src/backend/optimizer/plan/planagg.c index afb5445b77b..92ab5f5ab94 100644 --- a/src/backend/optimizer/plan/planagg.c +++ b/src/backend/optimizer/plan/planagg.c @@ -216,7 +216,7 @@ preprocess_minmax_aggregates(PlannerInfo *root) * doesn't need to change anymore, so making the pathtarget now is safe. */ grouped_rel = fetch_upper_rel(root, UPPERREL_GROUP_AGG, NULL); - add_path(grouped_rel, (Path *) + add_path(root, grouped_rel, (Path *) create_minmaxagg_path(root, grouped_rel, create_pathtarget(root, root->processed_tlist), diff --git a/src/backend/optimizer/plan/planmain.c b/src/backend/optimizer/plan/planmain.c index e17d31a5c3e..50207381d1f 100644 --- a/src/backend/optimizer/plan/planmain.c +++ b/src/backend/optimizer/plan/planmain.c @@ -133,7 +133,7 @@ query_planner(PlannerInfo *root, * SELECT is a kind of degenerate-grouping case, so it's not * that much of a cheat.) */ - add_path(final_rel, (Path *) + add_path(root, final_rel, (Path *) create_group_result_path(root, final_rel, final_rel->reltarget, (List *) parse->jointree->quals)); diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 948afd90948..8e6dd23df94 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -1992,7 +1992,7 @@ grouping_planner(PlannerInfo *root, double tuple_fraction, } /* And shove it into final_rel */ - add_path(final_rel, path); + add_path(root, final_rel, path); } /* @@ -3975,7 +3975,7 @@ create_degenerate_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel, (List *) parse->havingQual); } - add_path(grouped_rel, path); + add_path(root, grouped_rel, path); } /* @@ -4296,7 +4296,7 @@ consider_groupingsets_paths(PlannerInfo *root, strat = AGG_MIXED; } - add_path(grouped_rel, (Path *) + add_path(root, grouped_rel, (Path *) create_groupingsets_path(root, grouped_rel, path, @@ -4454,7 +4454,7 @@ consider_groupingsets_paths(PlannerInfo *root, if (rollups) { - add_path(grouped_rel, (Path *) + add_path(root, grouped_rel, (Path *) create_groupingsets_path(root, grouped_rel, path, @@ -4469,7 +4469,7 @@ consider_groupingsets_paths(PlannerInfo *root, * Now try the simple sorted case. */ if (!gd->unsortable_sets) - add_path(grouped_rel, (Path *) + add_path(root, grouped_rel, (Path *) create_groupingsets_path(root, grouped_rel, path, @@ -4735,7 +4735,7 @@ create_one_window_path(PlannerInfo *root, topwindow ? topqual : NIL, topwindow); } - add_path(window_rel, path); + add_path(root, window_rel, path); } /* @@ -5154,14 +5154,14 @@ create_final_distinct_paths(PlannerInfo *root, RelOptInfo *input_rel, * up with a duplicate LimitPath in the final plan. That does * not seem worth troubling over too much. */ - add_path(distinct_rel, (Path *) + add_path(root, distinct_rel, (Path *) create_limit_path(root, distinct_rel, sorted_path, NULL, limitCount, LIMIT_OPTION_COUNT, 0, 1)); } else { - add_path(distinct_rel, (Path *) + add_path(root, distinct_rel, (Path *) create_upper_unique_path(root, distinct_rel, sorted_path, list_length(root->distinct_pathkeys), @@ -5192,7 +5192,7 @@ create_final_distinct_paths(PlannerInfo *root, RelOptInfo *input_rel, if (allow_hash && grouping_is_hashable(root->processed_distinctClause)) { /* Generate hashed aggregate path --- no sort needed */ - add_path(distinct_rel, (Path *) + add_path(root, distinct_rel, (Path *) create_agg_path(root, distinct_rel, cheapest_input_path, @@ -5305,7 +5305,7 @@ create_ordered_paths(PlannerInfo *root, sorted_path = apply_projection_to_path(root, ordered_rel, sorted_path, target); - add_path(ordered_rel, sorted_path); + add_path(root, ordered_rel, sorted_path); } /* @@ -5383,7 +5383,7 @@ create_ordered_paths(PlannerInfo *root, sorted_path = apply_projection_to_path(root, ordered_rel, sorted_path, target); - add_path(ordered_rel, sorted_path); + add_path(root, ordered_rel, sorted_path); } } @@ -7024,7 +7024,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel, * We have aggregation, possibly with plain GROUP BY. Make * an AggPath. */ - add_path(grouped_rel, (Path *) + add_path(root, grouped_rel, (Path *) create_agg_path(root, grouped_rel, path, @@ -7042,7 +7042,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel, * We have GROUP BY without aggregation or grouping sets. * Make a GroupPath. */ - add_path(grouped_rel, (Path *) + add_path(root, grouped_rel, (Path *) create_group_path(root, grouped_rel, path, @@ -7094,7 +7094,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel, continue; if (parse->hasAggs) - add_path(grouped_rel, (Path *) + add_path(root, grouped_rel, (Path *) create_agg_path(root, grouped_rel, path, @@ -7106,7 +7106,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel, agg_final_costs, dNumGroups)); else - add_path(grouped_rel, (Path *) + add_path(root, grouped_rel, (Path *) create_group_path(root, grouped_rel, path, @@ -7136,7 +7136,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel, * Generate a HashAgg Path. We just need an Agg over the * cheapest-total input path, since input order won't matter. */ - add_path(grouped_rel, (Path *) + add_path(root, grouped_rel, (Path *) create_agg_path(root, grouped_rel, cheapest_path, grouped_rel->reltarget, @@ -7156,7 +7156,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel, { Path *path = partially_grouped_rel->cheapest_total_path; - add_path(grouped_rel, (Path *) + add_path(root, grouped_rel, (Path *) create_agg_path(root, grouped_rel, path, @@ -7345,7 +7345,7 @@ create_partial_grouping_paths(PlannerInfo *root, continue; if (parse->hasAggs) - add_path(partially_grouped_rel, (Path *) + add_path(root, partially_grouped_rel, (Path *) create_agg_path(root, partially_grouped_rel, path, @@ -7357,7 +7357,7 @@ create_partial_grouping_paths(PlannerInfo *root, agg_partial_costs, dNumPartialGroups)); else - add_path(partially_grouped_rel, (Path *) + add_path(root, partially_grouped_rel, (Path *) create_group_path(root, partially_grouped_rel, path, @@ -7433,7 +7433,7 @@ create_partial_grouping_paths(PlannerInfo *root, /* Checked above */ Assert(parse->hasAggs || parse->groupClause); - add_path(partially_grouped_rel, (Path *) + add_path(root, partially_grouped_rel, (Path *) create_agg_path(root, partially_grouped_rel, cheapest_total_path, @@ -7568,7 +7568,7 @@ gather_grouping_paths(PlannerInfo *root, RelOptInfo *rel) NULL, &total_groups); - add_path(rel, path); + add_path(root, rel, path); } } diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c index 1c69c6e97e8..f4875de8b45 100644 --- a/src/backend/optimizer/prep/prepunion.c +++ b/src/backend/optimizer/prep/prepunion.c @@ -486,7 +486,7 @@ generate_recursion_path(SetOperationStmt *setOp, PlannerInfo *root, root->wt_param_id, dNumGroups); - add_path(result_rel, path); + add_path(root, result_rel, path); postprocess_setop_rel(root, result_rel); return result_rel; } @@ -554,12 +554,12 @@ build_setop_child_paths(PlannerInfo *root, RelOptInfo *rel, make_tlist_from_pathtarget(subpath->pathtarget)); /* Generate outer path using this subpath */ - add_path(rel, (Path *) create_subqueryscan_path(root, - rel, - subpath, - trivial_tlist, - pathkeys, - NULL)); + add_path(root, rel, (Path *) create_subqueryscan_path(root, + rel, + subpath, + trivial_tlist, + pathkeys, + NULL)); } /* skip dealing with sorted paths if the setop doesn't need them */ @@ -622,12 +622,12 @@ build_setop_child_paths(PlannerInfo *root, RelOptInfo *rel, make_tlist_from_pathtarget(subpath->pathtarget)); /* Generate outer path using this subpath */ - add_path(rel, (Path *) create_subqueryscan_path(root, - rel, - subpath, - trivial_tlist, - pathkeys, - NULL)); + add_path(root, rel, (Path *) create_subqueryscan_path(root, + rel, + subpath, + trivial_tlist, + pathkeys, + NULL)); } } @@ -919,7 +919,7 @@ generate_union_paths(SetOperationStmt *op, PlannerInfo *root, NIL, NULL, dNumGroups); - add_path(result_rel, path); + add_path(root, result_rel, path); /* Try hash aggregate on the Gather path, if valid */ if (gpath != NULL) @@ -935,7 +935,7 @@ generate_union_paths(SetOperationStmt *op, PlannerInfo *root, NIL, NULL, dNumGroups); - add_path(result_rel, path); + add_path(root, result_rel, path); } } @@ -955,7 +955,7 @@ generate_union_paths(SetOperationStmt *op, PlannerInfo *root, list_length(path->pathkeys), dNumGroups); - add_path(result_rel, path); + add_path(root, result_rel, path); /* Try Sort -> Unique on the Gather path, if set */ if (gpath != NULL) @@ -971,7 +971,7 @@ generate_union_paths(SetOperationStmt *op, PlannerInfo *root, path, list_length(path->pathkeys), dNumGroups); - add_path(result_rel, path); + add_path(root, result_rel, path); } } @@ -996,16 +996,16 @@ generate_union_paths(SetOperationStmt *op, PlannerInfo *root, list_length(tlist), dNumGroups); - add_path(result_rel, path); + add_path(root, result_rel, path); } } else { /* UNION ALL */ - add_path(result_rel, apath); + add_path(root, result_rel, apath); if (gpath != NULL) - add_path(result_rel, gpath); + add_path(root, result_rel, gpath); } return result_rel; @@ -1188,7 +1188,7 @@ generate_nonunion_paths(SetOperationStmt *op, PlannerInfo *root, dNumOutputRows); result_rel->rows = path->rows; - add_path(result_rel, path); + add_path(root, result_rel, path); return result_rel; } diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index b8b1eae295e..91d394ce62e 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -417,7 +417,7 @@ set_cheapest(RelOptInfo *parent_rel) * Returns nothing, but modifies parent_rel->pathlist. */ void -add_path(RelOptInfo *parent_rel, Path *new_path) +add_path(PlannerInfo *root, RelOptInfo *parent_rel, Path *new_path) { bool accept_new = true; /* unless we find a superior old path */ int insert_at = 0; /* where to insert new item */ diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c index e05b21c884e..e3ac85d53dc 100644 --- a/src/backend/optimizer/util/relnode.c +++ b/src/backend/optimizer/util/relnode.c @@ -399,7 +399,7 @@ build_simple_rel(PlannerInfo *root, int relid, RelOptInfo *parent) * Restriction clause reduced to constant FALSE or NULL. Mark as * dummy so we won't scan this relation. */ - mark_dummy_rel(rel); + mark_dummy_rel(root, rel); } } diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h index 112e7c23d4e..15766e489fd 100644 --- a/src/include/optimizer/pathnode.h +++ b/src/include/optimizer/pathnode.h @@ -26,7 +26,7 @@ extern int compare_path_costs(Path *path1, Path *path2, extern int compare_fractional_path_costs(Path *path1, Path *path2, double fraction); extern void set_cheapest(RelOptInfo *parent_rel); -extern void add_path(RelOptInfo *parent_rel, Path *new_path); +extern void add_path(PlannerInfo *root, RelOptInfo *parent_rel, Path *new_path); extern bool add_path_precheck(RelOptInfo *parent_rel, Cost startup_cost, Cost total_cost, List *pathkeys, Relids required_outer); diff --git a/src/include/optimizer/paths.h b/src/include/optimizer/paths.h index 5c029b6b620..6fd45bc9dcd 100644 --- a/src/include/optimizer/paths.h +++ b/src/include/optimizer/paths.h @@ -108,7 +108,7 @@ extern bool have_join_order_restriction(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2); extern bool have_dangerous_phv(PlannerInfo *root, Relids outer_relids, Relids inner_params); -extern void mark_dummy_rel(RelOptInfo *rel); +extern void mark_dummy_rel(PlannerInfo *root, RelOptInfo *rel); extern void init_dummy_sjinfo(SpecialJoinInfo *sjinfo, Relids left_relids, Relids right_relids); -- 2.39.3 (Apple Git-146)