mirror of
https://github.com/postgres/postgres.git
synced 2025-07-12 21:01:52 +03:00
Change set_plan_references and join_references to take an rtable List
rather than a Query node; this allows set_plan_references to recurse into subplans correctly. Fixes core dump on full outer joins in subplans. Also, invoke preprocess_expression on function RTEs' function expressions. This seems to fix the planner's problems with outer-level Vars in function RTEs.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.117 2002/05/12 23:43:03 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.118 2002/05/18 02:25:49 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -101,7 +101,7 @@ planner(Query *parse)
|
||||
result_plan->nParamExec = length(PlannerParamVar);
|
||||
|
||||
/* final cleanup of the plan */
|
||||
set_plan_references(parse, result_plan);
|
||||
set_plan_references(result_plan, parse->rtable);
|
||||
|
||||
/* restore state for outer planner, if any */
|
||||
PlannerQueryLevel = save_PlannerQueryLevel;
|
||||
@ -175,6 +175,17 @@ subquery_planner(Query *parse, double tuple_fraction)
|
||||
parse->havingQual = preprocess_expression(parse, parse->havingQual,
|
||||
EXPRKIND_HAVING);
|
||||
|
||||
/* Also need to preprocess expressions for function RTEs */
|
||||
foreach(lst, parse->rtable)
|
||||
{
|
||||
RangeTblEntry *rte = (RangeTblEntry *) lfirst(lst);
|
||||
|
||||
if (rte->rtekind == RTE_FUNCTION)
|
||||
rte->funcexpr = preprocess_expression(parse, rte->funcexpr,
|
||||
EXPRKIND_TARGET);
|
||||
/* These are not targetlist items, but close enough... */
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for ungrouped variables passed to subplans in targetlist and
|
||||
* HAVING clause (but not in WHERE or JOIN/ON clauses, since those are
|
||||
@ -737,7 +748,7 @@ preprocess_expression(Query *parse, Node *expr, int kind)
|
||||
}
|
||||
}
|
||||
if (has_join_rtes)
|
||||
expr = flatten_join_alias_vars(expr, parse, false);
|
||||
expr = flatten_join_alias_vars(expr, parse->rtable, false);
|
||||
|
||||
return expr;
|
||||
}
|
||||
|
Reference in New Issue
Block a user