From c38023811617c2971bc47a0af42c568eb856abdb Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Fri, 15 Aug 2008 12:38:46 -0300 Subject: [PATCH] Bug#38560: valgrind warnings on PB due to query profiling Fix for a valgrind warning due to a jump on a uninitialized variable. The problem was that the sql profile preparation function wasn't being called for all possible code paths of query execution. The solution is to ensure that query profiling is always started before dispatch_command function is called and to explicitly call the profile preparation function on bootstrap. --- sql/sql_parse.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index d9ec8f6c610..dfa8233a37f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -329,6 +329,12 @@ void execute_init_command(THD *thd, sys_var_str *init_command_var, Vio* save_vio; ulong save_client_capabilities; +#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER) + thd->profiling.start_new_query(); + thd->profiling.set_query_source(init_command_var->value, + init_command_var->value_length); +#endif + thd_proc_info(thd, "Execution of init_command"); /* We need to lock init_command_var because @@ -350,6 +356,10 @@ void execute_init_command(THD *thd, sys_var_str *init_command_var, rw_unlock(var_mutex); thd->client_capabilities= save_client_capabilities; thd->net.vio= save_vio; + +#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER) + thd->profiling.finish_current_query(); +#endif } @@ -441,6 +451,7 @@ pthread_handler_t handle_bootstrap(void *arg) thd->query[length] = '\0'; DBUG_PRINT("query",("%-.4096s",thd->query)); #if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER) + thd->profiling.start_new_query(); thd->profiling.set_query_source(thd->query, length); #endif @@ -456,6 +467,10 @@ pthread_handler_t handle_bootstrap(void *arg) bootstrap_error= thd->is_error(); net_end_statement(thd); +#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER) + thd->profiling.finish_current_query(); +#endif + if (bootstrap_error) break;