mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-27306: SET STATEMENT optimizer_trace=1 Doesn't save the trace
In mysql_execute_command(), move optimizer trace initialization to be after run_set_statement_if_requested() call. Unfortunately, mysql_execute_command() code uses "goto error" a lot, and this means optimizer trace code cannot use RAII objects. Work this around by: - Make Opt_trace_start a non-RAII object, add init() method. - Move the code that writes the top-level object and array into Opt_trace_start::init().
This commit is contained in:
@ -3644,12 +3644,7 @@ mysql_execute_command(THD *thd, bool is_called_from_prepared_stmt)
|
||||
#ifdef HAVE_REPLICATION
|
||||
} /* endif unlikely slave */
|
||||
#endif
|
||||
Opt_trace_start ots(thd, all_tables, lex->sql_command, &lex->var_list,
|
||||
thd->query(), thd->query_length(),
|
||||
thd->variables.character_set_client);
|
||||
|
||||
Json_writer_object trace_command(thd);
|
||||
Json_writer_array trace_command_steps(thd, "steps");
|
||||
Opt_trace_start ots(thd);
|
||||
|
||||
/* store old value of binlog format */
|
||||
enum_binlog_format orig_binlog_format,orig_current_stmt_binlog_format;
|
||||
@ -3715,6 +3710,10 @@ mysql_execute_command(THD *thd, bool is_called_from_prepared_stmt)
|
||||
if (run_set_statement_if_requested(thd, lex))
|
||||
goto error;
|
||||
|
||||
/* After SET STATEMENT is done, we can initialize the Optimizer Trace: */
|
||||
ots.init(thd, all_tables, lex->sql_command, &lex->var_list, thd->query(),
|
||||
thd->query_length(), thd->variables.character_set_client);
|
||||
|
||||
if (thd->lex->mi.connection_name.str == NULL)
|
||||
thd->lex->mi.connection_name= thd->variables.default_master_connection;
|
||||
|
||||
|
Reference in New Issue
Block a user