• R/O
  • HTTP
  • SSH
  • HTTPS

pg_hint_plan: コミット

firtst release


コミットメタ情報

リビジョンbd305989c398b9dec50177638ec7e825b90496f3 (tree)
日時2014-12-17 10:26:20
作者Kyotaro Horiguchi <horiguchi.kyotaro@lab....>
コミッターKyotaro Horiguchi

ログメッセージ

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.

変更サマリ

差分

--- 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
旧リポジトリブラウザで表示