diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2019-03-27 12:57:41 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2019-03-27 12:57:49 -0400 |
commit | 333ed246c6f351c4e8fe22c764b97793c4101b00 (patch) | |
tree | eb591e4b8c174e3f35bccaba87c6786b970e889d /src/backend/optimizer/plan/planmain.c | |
parent | 9938d116331045171f37eef359992ec64c213384 (diff) | |
download | postgresql-333ed246c6f351c4e8fe22c764b97793c4101b00.tar.gz |
Avoid passing query tlist around separately from root->processed_tlist.
In the dim past, the planner kept the fully-processed version of the query
targetlist (the result of preprocess_targetlist) in grouping_planner's
local variable "tlist", and only grudgingly passed it to individual other
routines as needed. Later we discovered a need to still have it available
after grouping_planner finishes, and invented the root->processed_tlist
field for that purpose, but it wasn't used internally to grouping_planner;
the tlist was still being passed around separately in the same places as
before.
Now comes a proposed patch to allow appendrel expansion to add entries
to the processed tlist, well after preprocess_targetlist has finished
its work. To avoid having to pass around the tlist explicitly, it's
proposed to allow appendrel expansion to modify root->processed_tlist.
That makes aliasing the tlist with assorted parameters and local
variables really scary. It would accidentally work as long as the
tlist is initially nonempty, because then the List header won't move
around, but it's not exactly hard to think of ways for that to break.
Aliased values are poor programming practice anyway.
Hence, get rid of local variables and parameters that can be identified
with root->processed_tlist, in favor of just using that field directly.
And adjust comments to match. (Some of the new comments speak as though
it's already possible for appendrel expansion to modify the tlist; that's
not true yet, but will happen in a later patch.)
Discussion: https://postgr.es/m/9d7c5112-cb99-6a47-d3be-cf1ee6862a1d@lab.ntt.co.jp
Diffstat (limited to 'src/backend/optimizer/plan/planmain.c')
-rw-r--r-- | src/backend/optimizer/plan/planmain.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/backend/optimizer/plan/planmain.c b/src/backend/optimizer/plan/planmain.c index c36958de51..2dbf1db844 100644 --- a/src/backend/optimizer/plan/planmain.c +++ b/src/backend/optimizer/plan/planmain.c @@ -42,8 +42,6 @@ * (grouping_planner) can choose among the surviving paths for the rel. * * root describes the query to plan - * tlist is the target list the query should produce - * (this is NOT necessarily root->parse->targetList!) * qp_callback is a function to compute query_pathkeys once it's safe to do so * qp_extra is optional extra data to pass to qp_callback * @@ -54,7 +52,7 @@ * (We cannot construct canonical pathkeys until that's done.) */ RelOptInfo * -query_planner(PlannerInfo *root, List *tlist, +query_planner(PlannerInfo *root, query_pathkeys_callback qp_callback, void *qp_extra) { Query *parse = root->parse; @@ -179,7 +177,7 @@ query_planner(PlannerInfo *root, List *tlist, * restrictions. Finally, we form a target joinlist for make_one_rel() to * work from. */ - build_base_rel_tlists(root, tlist); + build_base_rel_tlists(root, root->processed_tlist); find_placeholders_in_jointree(root); |