]> granicus.if.org Git - postgresql/commit
Rearrange planner to save the whole PlannerInfo (subroot) for a subquery.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 3 Sep 2011 19:35:12 +0000 (15:35 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 3 Sep 2011 19:36:24 +0000 (15:36 -0400)
commitb3aaf9081a1a95c245fd605dcf02c91b3a5c3a29
treec3c0c1bd1fdc77722d139f1add99c7abb7a922ef
parent42ad992fdc25fa69db03ff242216f6712da2c56a
Rearrange planner to save the whole PlannerInfo (subroot) for a subquery.

Formerly, set_subquery_pathlist and other creators of plans for subqueries
saved only the rangetable and rowMarks lists from the lower-level
PlannerInfo.  But there's no reason not to remember the whole PlannerInfo,
and indeed this turns out to simplify matters in a number of places.

The immediate reason for doing this was so that the subroot will still be
accessible when we're trying to extract column statistics out of an
already-planned subquery.  But now that I've done it, it seems like a good
code-beautification effort in its own right.

I also chose to get rid of the transient subrtable and subrowmark fields in
SubqueryScan nodes, in favor of having setrefs.c look up the subquery's
RelOptInfo.  That required changing all the APIs in setrefs.c to pass
PlannerInfo not PlannerGlobal, which was a large but quite mechanical
transformation.

One side-effect not foreseen at the beginning is that this finally broke
inheritance_planner's assumption that replanning the same subquery RTE N
times would necessarily give interchangeable results each time.  That
assumption was always pretty risky, but now we really have to make a
separate RTE for each instance so that there's a place to carry the
separate subroots.
19 files changed:
src/backend/executor/nodeSubqueryscan.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/outfuncs.c
src/backend/optimizer/path/allpaths.c
src/backend/optimizer/path/costsize.c
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/plan/planmain.c
src/backend/optimizer/plan/planner.c
src/backend/optimizer/plan/setrefs.c
src/backend/optimizer/plan/subselect.c
src/backend/optimizer/prep/prepunion.c
src/backend/optimizer/util/clauses.c
src/backend/optimizer/util/relnode.c
src/backend/rewrite/rewriteManip.c
src/include/nodes/plannodes.h
src/include/nodes/relation.h
src/include/optimizer/cost.h
src/include/optimizer/pathnode.h
src/include/optimizer/planmain.h