• R/O
  • HTTP
  • SSH
  • HTTPS

pg_hint_plan: Commit

firtst release


Commit MetaInfo

Revision1f489193eca11d14e223f4f288990525254d6c24 (tree)
Time2014-12-18 16:37:12
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
@@ -527,7 +527,9 @@ static const HintParser parsers[] = {
527527 * PL/pgSQL plugin for retrieving string representation of each query during
528528 * function execution.
529529 */
530-const char *plpgsql_query_string = NULL;
530+static const char *plpgsql_query_string = NULL;
531+static enum PLpgSQL_stmt_types plpgsql_query_string_src;
532+
531533 PLpgSQL_plugin plugin_funcs = {
532534 NULL,
533535 NULL,
@@ -4068,7 +4070,10 @@ pg_hint_plan_plpgsql_stmt_beg(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt)
40684070 }
40694071
40704072 if (expr)
4073+ {
40714074 plpgsql_query_string = expr->query;
4075+ plpgsql_query_string_src = (enum PLpgSQL_stmt_types) stmt->cmd_type;
4076+ }
40724077 }
40734078
40744079 /*
@@ -4079,7 +4084,8 @@ pg_hint_plan_plpgsql_stmt_beg(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt)
40794084 static void
40804085 pg_hint_plan_plpgsql_stmt_end(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt)
40814086 {
4082- if ((enum PLpgSQL_stmt_types) stmt->cmd_type == PLPGSQL_STMT_EXECSQL)
4087+ if (plpgsql_query_string &&
4088+ plpgsql_query_string_src == stmt->cmd_type)
40834089 plpgsql_query_string = NULL;
40844090 }
40854091
Show on old repository browser