firtst release
Revisión | 4e63a22d0aeb67b03f05ddc689f25e8a0b27ef91 (tree) |
---|---|
Tiempo | 2020-02-17 21:08:43 |
Autor | Kyotaro Horiguchi <horikyota.ntt@gmai...> |
Commiter | Kyotaro Horiguchi |
Restore current hint state when returned from non-hinted query planning.
If no hint is given for the current level query, pg_hint_plan_planner
calls the next level of planner after erasing the
current_hint_state. But it forgot to restore the state before the
planning of the rest part of the current-level query. It is broken by
the commit 958c60d but overlooked among vast amount of behavioral
changes.. Get back the behavior by restoring current_hint_state after
returned from the lower level planner with unhinted query.
Issue: https://github.com/ossc-db/pg_hint_plan/issues/30
Reported-by: higuchi-daisuke
@@ -4260,7 +4260,12 @@ SQL statement "SELECT /*+ IndexScan(t_1) */ nested_planner(cnt - 1) | ||
4260 | 4260 | ORDER BY t_1.c1 LIMIT 1" |
4261 | 4261 | PL/pgSQL function nested_planner(integer) line 12 at SQL statement |
4262 | 4262 | LOG: pg_hint_plan: |
4263 | -no hint | |
4263 | +used hint: | |
4264 | +IndexScan(t_1) | |
4265 | +not used hint: | |
4266 | +duplication hint: | |
4267 | +error hint: | |
4268 | + | |
4264 | 4269 | CONTEXT: SQL statement "SELECT /*+ IndexScan(t_1) */ nested_planner(cnt - 1) FROM s1.t1 t_1 |
4265 | 4270 | JOIN s1.t2 t_2 ON (t_1.c1 = t_2.c1) |
4266 | 4271 | ORDER BY t_1.c1 LIMIT 1" |
@@ -2863,9 +2863,15 @@ standard_planner_proc: | ||
2863 | 2863 | } |
2864 | 2864 | current_hint = NULL; |
2865 | 2865 | if (prev_planner) |
2866 | - return (*prev_planner) (parse, cursorOptions, boundParams); | |
2866 | + result = (*prev_planner) (parse, cursorOptions, boundParams); | |
2867 | 2867 | else |
2868 | - return standard_planner(parse, cursorOptions, boundParams); | |
2868 | + result = standard_planner(parse, cursorOptions, boundParams); | |
2869 | + | |
2870 | + /* The upper-level planner still needs the current hint state */ | |
2871 | + if (HintStateStack != NIL) | |
2872 | + current_hint = (HintState *) lfirst(list_head(HintStateStack)); | |
2873 | + | |
2874 | + return result; | |
2869 | 2875 | } |
2870 | 2876 | |
2871 | 2877 | /* |