Commit 02cd7856 authored by Davi Arnaut's avatar Davi Arnaut

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:
  Finish query profiling properly when executing bootstrap commands.
  Add query profiling to execute_init_command as it calls dispatch_command.
parent 02aaff1b
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment