firtst release
Révision | 9db100fedece81e8774b299341d266b514627026 (tree) |
---|---|
l'heure | 2020-02-17 21:08:52 |
Auteur | 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
(a-kind-of) broken by the commit 2c73975 and d1a839a but overlooked by
assuming the required side-effect of the fix. 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" |
@@ -4278,7 +4283,12 @@ SQL statement "SELECT /*+ IndexScan(t_1) */ nested_planner(cnt - 1) | ||
4278 | 4283 | ORDER BY t_1.c1 LIMIT 1" |
4279 | 4284 | PL/pgSQL function nested_planner(integer) line 12 at SQL statement |
4280 | 4285 | LOG: pg_hint_plan: |
4281 | -no hint | |
4286 | +used hint: | |
4287 | +IndexScan(t_1) | |
4288 | +not used hint: | |
4289 | +duplication hint: | |
4290 | +error hint: | |
4291 | + | |
4282 | 4292 | CONTEXT: SQL statement "SELECT /*+ IndexScan(t_1) */ nested_planner(cnt - 1) FROM s1.t1 t_1 |
4283 | 4293 | JOIN s1.t2 t_2 ON (t_1.c1 = t_2.c1) |
4284 | 4294 | ORDER BY t_1.c1 LIMIT 1" |
@@ -2858,9 +2858,14 @@ standard_planner_proc: | ||
2858 | 2858 | } |
2859 | 2859 | current_hint = NULL; |
2860 | 2860 | if (prev_planner) |
2861 | - return (*prev_planner) (parse, cursorOptions, boundParams); | |
2861 | + result = (*prev_planner) (parse, cursorOptions, boundParams); | |
2862 | 2862 | else |
2863 | - return standard_planner(parse, cursorOptions, boundParams); | |
2863 | + result = standard_planner(parse, cursorOptions, boundParams); | |
2864 | + | |
2865 | + if (HintStateStack) | |
2866 | + current_hint = (HintState *) lfirst(list_head(HintStateStack)); | |
2867 | + | |
2868 | + return result; | |
2864 | 2869 | } |
2865 | 2870 | |
2866 | 2871 | /* |