firtst release
Revision | 45ca0332695be1c386374dd2782f65c86dbc943c (tree) |
---|---|
Time | 2014-12-17 10:46:52 |
Author | Kyotaro Horiguchi <horiguchi.kyotaro@lab....> |
Commiter | 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.
@@ -490,7 +490,9 @@ static const HintParser parsers[] = { | ||
490 | 490 | * PL/pgSQL plugin for retrieving string representation of each query during |
491 | 491 | * function execution. |
492 | 492 | */ |
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 | + | |
494 | 496 | PLpgSQL_plugin plugin_funcs = { |
495 | 497 | NULL, |
496 | 498 | NULL, |
@@ -3682,7 +3684,10 @@ pg_hint_plan_plpgsql_stmt_beg(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt) | ||
3682 | 3684 | } |
3683 | 3685 | |
3684 | 3686 | if (expr) |
3687 | + { | |
3685 | 3688 | plpgsql_query_string = expr->query; |
3689 | + plpgsql_query_string_src = (enum PLpgSQL_stmt_types) stmt->cmd_type; | |
3690 | + } | |
3686 | 3691 | } |
3687 | 3692 | |
3688 | 3693 | /* |
@@ -3693,7 +3698,8 @@ pg_hint_plan_plpgsql_stmt_beg(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt) | ||
3693 | 3698 | static void |
3694 | 3699 | pg_hint_plan_plpgsql_stmt_end(PLpgSQL_execstate *estate, PLpgSQL_stmt *stmt) |
3695 | 3700 | { |
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) | |
3697 | 3703 | plpgsql_query_string = NULL; |
3698 | 3704 | } |
3699 | 3705 |