]> granicus.if.org Git - postgresql/commit
Add a concept of "placeholder" variables to the planner. These are variables
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 21 Oct 2008 20:42:53 +0000 (20:42 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 21 Oct 2008 20:42:53 +0000 (20:42 +0000)
commite6ae3b5dbf2c07bceb737c5a0ff199b1156051d1
treeb8616c6b889741b53c282574195fc41317778dfd
parent831abae5061b98b7f203a24af7badeaaeb15808f
Add a concept of "placeholder" variables to the planner.  These are variables
that represent some expression that we desire to compute below the top level
of the plan, and then let that value "bubble up" as though it were a plain
Var (ie, a column value).

The immediate application is to allow sub-selects to be flattened even when
they are below an outer join and have non-nullable output expressions.
Formerly we couldn't flatten because such an expression wouldn't properly
go to NULL when evaluated above the outer join.  Now, we wrap it in a
PlaceHolderVar and arrange for the actual evaluation to occur below the outer
join.  When the resulting Var bubbles up through the join, it will be set to
NULL if necessary, yielding the correct results.  This fixes a planner
limitation that's existed since 7.1.

In future we might want to use this mechanism to re-introduce some form of
Hellerstein's "expensive functions" optimization, ie place the evaluation of
an expensive function at the most suitable point in the plan tree.
28 files changed:
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/nodes/nodeFuncs.c
src/backend/nodes/outfuncs.c
src/backend/optimizer/path/allpaths.c
src/backend/optimizer/path/costsize.c
src/backend/optimizer/path/equivclass.c
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/plan/initsplan.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/prepjointree.c
src/backend/optimizer/prep/preptlist.c
src/backend/optimizer/prep/prepunion.c
src/backend/optimizer/util/Makefile
src/backend/optimizer/util/clauses.c
src/backend/optimizer/util/placeholder.c [new file with mode: 0644]
src/backend/optimizer/util/relnode.c
src/backend/optimizer/util/tlist.c
src/backend/optimizer/util/var.c
src/backend/rewrite/rewriteManip.c
src/backend/utils/adt/selfuncs.c
src/include/nodes/nodes.h
src/include/nodes/relation.h
src/include/optimizer/placeholder.h [new file with mode: 0644]
src/include/optimizer/var.h