aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/plan/planner.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-03-18 22:04:14 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-03-18 22:04:14 +0000
commit0d49838df6f54c5b49d40a8cf396ea799bd3c4d9 (patch)
tree10bc9771479d02eb22a9a2fcec20e758ad5715bb /src/backend/optimizer/plan/planner.c
parent433c5238bf1980b917b758f3003f16f134c34540 (diff)
downloadpostgresql-0d49838df6f54c5b49d40a8cf396ea799bd3c4d9.tar.gz
postgresql-0d49838df6f54c5b49d40a8cf396ea799bd3c4d9.zip
Arrange to "inline" SQL functions that appear in a query's FROM clause,
are declared to return set, and consist of just a single SELECT. We can replace the FROM-item with a sub-SELECT and then optimize much as if we were dealing with a view. Patch from Richard Rowell, cleaned up by me.
Diffstat (limited to 'src/backend/optimizer/plan/planner.c')
-rw-r--r--src/backend/optimizer/plan/planner.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index 0103ea826ca..2f469bd924e 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.226 2008/01/01 19:45:50 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.227 2008/03/18 22:04:14 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -253,14 +253,21 @@ subquery_planner(PlannerGlobal *glob, Query *parse,
/*
* Look for IN clauses at the top level of WHERE, and transform them into
* joins. Note that this step only handles IN clauses originally at top
- * level of WHERE; if we pull up any subqueries in the next step, their
- * INs are processed just before pulling them up.
+ * level of WHERE; if we pull up any subqueries below, their INs are
+ * processed just before pulling them up.
*/
if (parse->hasSubLinks)
parse->jointree->quals = pull_up_IN_clauses(root,
parse->jointree->quals);
/*
+ * Scan the rangetable for set-returning functions, and inline them
+ * if possible (producing subqueries that might get pulled up next).
+ * Recursion issues here are handled in the same way as for IN clauses.
+ */
+ inline_set_returning_functions(root);
+
+ /*
* Check to see if any subqueries in the rangetable can be merged into
* this query.
*/