Commit 26f0d72a authored by Alexander Barkov's avatar Alexander Barkov

A cleanup for MDEV-18333 Slow_queries count doesn't increase when slow_query_log is turned off

thd->lex->m_sql_cmd was not cleared between queries.
log_slow_query() could crash (when running mtr --ps) because of this.
parent 485dcb07
......@@ -1989,6 +1989,11 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
dec_thread_running();
thd->packet.shrink(thd->variables.net_buffer_length); // Reclaim some memory
thd->reset_kill_query(); /* Ensure that killed_errmsg is released */
/*
LEX::m_sql_cmd can point to Sql_cmd allocated on thd->mem_root.
Unlink it now, before freeing the root.
*/
thd->lex->m_sql_cmd= NULL;
free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
#if defined(ENABLED_PROFILING)
......
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