• R/O
  • HTTP
  • SSH
  • HTTPS

pg_hint_plan: Commit

firtst release


Commit MetaInfo

Revision45ca0332695be1c386374dd2782f65c86dbc943c (tree)
Time2014-12-17 10:46:52
AuthorKyotaro Horiguchi <horiguchi.kyotaro@lab....>
CommiterKyotaro Horiguchi

Log Message

Fix about unexpectedly living plpgsql query string.

pg_hint_plan forgot to erase plpgsql query strings when it is NOT a
static statement, so it continued to read hints from the remenbered
wrong query string after using dynamic execution of a statement. This
commit makes it to be erased for any types of pl/pgsql statement.

Change Summary

Incremental Difference

--- a/pg_hint_plan.c
+++ b/pg_hint_plan.c
@@ -490,7 +490,9 @@ static const HintParser parsers[] = {
490490 * PL/pgSQL plugin for retrieving string representation of each query during
491491 * function execution.
492492 */
493-const char *plpgsql_query_string = NULL;
493+static const char *plpgsql_query_string = NULL;
494+static enum PLpgSQL_stmt_types plpgsql_query_string_src;
495+
494496 PLpgSQL_plugin plugin_funcs = {
495497 NULL,
496498 NULL,
@@ -3682,7 +3684,10 @@ pg_hint_plan_plpgsql_stmt_beg(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt)
36823684 }
36833685
36843686 if (expr)
3687+ {
36853688 plpgsql_query_string = expr->query;
3689+ plpgsql_query_string_src = (enum PLpgSQL_stmt_types) stmt->cmd_type;
3690+ }
36863691 }
36873692
36883693 /*
@@ -3693,7 +3698,8 @@ pg_hint_plan_plpgsql_stmt_beg(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt)
36933698 static void
36943699 pg_hint_plan_plpgsql_stmt_end(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt)
36953700 {
3696- if ((enum PLpgSQL_stmt_types) stmt->cmd_type == PLPGSQL_STMT_EXECSQL)
3701+ if (plpgsql_query_string &&
3702+ plpgsql_query_string_src == stmt->cmd_type)
36973703 plpgsql_query_string = NULL;
36983704 }
36993705
Show on old repository browser