mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
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.
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user