Re: Bug with 'iscachable' attribute (Was: Index selection bug)
От | Tom Lane |
---|---|
Тема | Re: Bug with 'iscachable' attribute (Was: Index selection bug) |
Дата | |
Msg-id | 14770.964742181@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Bug with 'iscachable' attribute (Was: Index selection bug) (Andriy I Pilipenko <bamby@marka.net.ua>) |
Список | pgsql-bugs |
Andriy I Pilipenko <bamby@marka.net.ua> writes: > create function f() returns int as ' > select a > from a > where a = (select max(b) from b) > ' language 'sql' > with (iscachable) > select f() > ERROR: replace_vars_with_subplan_refs: variable not in subplan target list Fixed by the attached patch. Thanks for the report! regards, tom lane *** src/backend/optimizer/plan/planner.c.orig Wed Apr 12 13:15:22 2000 --- src/backend/optimizer/plan/planner.c Thu Jul 27 19:53:29 2000 *************** *** 53,58 **** --- 53,74 ---- planner(Query *parse) { Plan *result_plan; + Index save_PlannerQueryLevel; + List *save_PlannerInitPlan; + List *save_PlannerParamVar; + int save_PlannerPlanId; + + /* + * The planner can be called recursively (an example is when + * eval_const_expressions tries to simplify an SQL function). + * So, global state variables must be saved and restored. + * + * (Perhaps these should be moved into the Query structure instead?) + */ + save_PlannerQueryLevel = PlannerQueryLevel; + save_PlannerInitPlan = PlannerInitPlan; + save_PlannerParamVar = PlannerParamVar; + save_PlannerPlanId = PlannerPlanId; /* Initialize state for subselects */ PlannerQueryLevel = 1; *************** *** 80,85 **** --- 96,107 ---- /* final cleanup of the plan */ set_plan_references(result_plan); + + /* restore state for outer planner, if any */ + PlannerQueryLevel = save_PlannerQueryLevel; + PlannerInitPlan = save_PlannerInitPlan; + PlannerParamVar = save_PlannerParamVar; + PlannerPlanId = save_PlannerPlanId; return result_plan; }
В списке pgsql-bugs по дате отправления: