• R/O
  • HTTP
  • SSH
  • HTTPS

pg_hint_plan: Commit

firtst release


Commit MetaInfo

Revision285b67d7b12abd56ec12db551cf06a40ae6c1baf (tree)
Time2020-02-17 21:08:26
AuthorKyotaro Horiguchi <horikyota.ntt@gmai...>
CommiterKyotaro Horiguchi

Log Message

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 d422966 but overlooked as an
inevitable 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

Change Summary

Incremental Difference

--- a/expected/ut-A.out
+++ b/expected/ut-A.out
@@ -4262,7 +4262,12 @@ NOTICE: nested_planner(3)
42624262 NOTICE: nested_planner(2)
42634263 NOTICE: nested_planner(1)
42644264 LOG: pg_hint_plan:
4265-no hint
4265+used hint:
4266+IndexScan(t_1)
4267+not used hint:
4268+duplication hint:
4269+error hint:
4270+
42664271 LOG: pg_hint_plan:
42674272 used hint:
42684273 IndexScan(t_1)
--- a/pg_hint_plan.c
+++ b/pg_hint_plan.c
@@ -3197,9 +3197,14 @@ standard_planner_proc:
31973197 }
31983198 current_hint_state = NULL;
31993199 if (prev_planner)
3200- return (*prev_planner) (parse, cursorOptions, boundParams);
3200+ result = (*prev_planner) (parse, cursorOptions, boundParams);
32013201 else
3202- return standard_planner(parse, cursorOptions, boundParams);
3202+ result = standard_planner(parse, cursorOptions, boundParams);
3203+
3204+ if(HintStateStack != NIL)
3205+ current_hint_state = (HintState *) lfirst(list_head(HintStateStack));
3206+
3207+ return result;
32033208 }
32043209
32053210 /*
Show on old repository browser