pgsql: Rearrange planner to save the whole PlannerInfo (subroot) for a

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Rearrange planner to save the whole PlannerInfo (subroot) for a
Date: 2011-09-03 19:36:44
Message-ID: E1Qzw1E-0005ak-DO@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/b3aaf9081a1a95c245fd605dcf02c91b3a5c3a29

Modified Files
--------------
src/backend/executor/nodeSubqueryscan.c | 7 +-
src/backend/nodes/copyfuncs.c | 2 -
src/backend/nodes/outfuncs.c | 8 +-
src/backend/optimizer/path/allpaths.c | 5 +-
src/backend/optimizer/path/costsize.c | 4 +-
src/backend/optimizer/plan/createplan.c | 10 +-
src/backend/optimizer/plan/planmain.c | 20 +--
src/backend/optimizer/plan/planner.c | 198 ++++++++++++++++------
src/backend/optimizer/plan/setrefs.c | 278 +++++++++++++++---------------
src/backend/optimizer/plan/subselect.c | 34 ++---
src/backend/optimizer/prep/prepunion.c | 30 +++-
src/backend/optimizer/util/clauses.c | 17 +--
src/backend/optimizer/util/relnode.c | 35 ++++-
src/backend/rewrite/rewriteManip.c | 16 ++
src/include/nodes/plannodes.h | 6 -
src/include/nodes/relation.h | 12 +-
src/include/optimizer/cost.h | 3 +-
src/include/optimizer/pathnode.h | 1 +
src/include/optimizer/planmain.h | 12 +-
19 files changed, 394 insertions(+), 304 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2011-09-03 20:18:27 pgsql: Fix typo in pg_srand48 (srand48 in older branches).
Previous Message Bruce Momjian 2011-09-03 14:39:15 Re: pgsql: Remove "fmgr.h" include in cube contrib --- caused crash on a Ge