diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-03-21 05:12:12 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-03-21 05:12:12 +0000 |
| commit | 3ee8f7e207b3459372e13603023a9d84bb800e0b (patch) | |
| tree | 74c0afa6e70d62f8df75b90900c19645356f3895 /src/backend/optimizer/prep | |
| parent | aafe86d9959f1c5adfc1d0c6f8ab54609017f182 (diff) | |
| download | postgresql-3ee8f7e207b3459372e13603023a9d84bb800e0b.tar.gz | |
Restructure planning code so that preprocessing of targetlist and quals
to simplify constant expressions and expand SubLink nodes into SubPlans
is done in a separate routine subquery_planner() that calls union_planner().
We formerly did most of this work in query_planner(), but that's the
wrong place because it may never see the real targetlist. Splitting
union_planner into two routines also allows us to avoid redundant work
when union_planner is invoked recursively for UNION and inheritance
cases. Upshot is that it is now possible to do something like
select float8(count(*)) / (select count(*) from int4_tbl) from int4_tbl
group by f1;
which has never worked before.
Diffstat (limited to 'src/backend/optimizer/prep')
| -rw-r--r-- | src/backend/optimizer/prep/prepunion.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c index c0e09dc6d9..e866a5032f 100644 --- a/src/backend/optimizer/prep/prepunion.c +++ b/src/backend/optimizer/prep/prepunion.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.46 2000/03/14 23:06:29 thomas Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.47 2000/03/21 05:12:06 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -149,8 +149,12 @@ plan_union_queries(Query *parse) { Query *union_query = lfirst(ulist); + /* use subquery_planner here because the union'd queries + * have not been preprocessed yet. My goodness this is messy... + */ union_plans = lappend(union_plans, - union_planner(union_query, tuple_fraction)); + subquery_planner(union_query, + tuple_fraction)); union_rts = lappend(union_rts, union_query->rtable); } } @@ -185,8 +189,11 @@ plan_union_queries(Query *parse) { Query *union_all_query = lfirst(ulist); + /* use subquery_planner here because the union'd queries + * have not been preprocessed yet. My goodness this is messy... + */ union_plans = lappend(union_plans, - union_planner(union_all_query, -1.0)); + subquery_planner(union_all_query, -1.0)); union_rts = lappend(union_rts, union_all_query->rtable); } } |
