mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-28201: Server crashes upon SHOW ANALYZE/EXPLAIN FORMAT=JSON
- Describe the lifetime of EXPLAIN data structures in sql_explain.h:ExplainDataStructureLifetime. - Make Item_field::set_field() call set_refers_to_temp_table() when it refers to a temp. table. - Introduce QT_DONT_ACCESS_TMP_TABLES flag for Item::print. It directs Item_field::print to not try access its the temp table. - Introduce Explain_query::notify_tables_are_closed() and call it right before the query closes its tables. - Make Explain data stuctures' print_explain_json() methods accept "no_tmp_tbl" parameter which means pass QT_DONT_ACCESS_TMP_TABLES when printing items. - Make Show_explain_request::call_in_target_thread() not call set_current_thd(). This wasn't needed as the code inside lex->print_explain() uses output->thd anyway. output->thd refers to the SHOW command's THD object.
This commit is contained in:
@ -2575,11 +2575,6 @@ void log_slow_statement(THD *thd)
|
||||
|
||||
end:
|
||||
delete_explain_query(thd->lex);
|
||||
DBUG_EXECUTE_IF("log_slow_statement_end",
|
||||
if (dbug_user_var_equals_str(thd, "show_explain_probe_query",
|
||||
thd->query()))
|
||||
dbug_serve_apcs(thd, 1);
|
||||
);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
@ -6074,7 +6069,7 @@ finish:
|
||||
}
|
||||
|
||||
/* Free tables. Set stage 'closing tables' */
|
||||
close_thread_tables(thd);
|
||||
close_thread_tables_for_query(thd);
|
||||
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
@ -6223,7 +6218,8 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables)
|
||||
result->remove_offset_limit();
|
||||
if (lex->explain_json)
|
||||
{
|
||||
lex->explain->print_explain_json(result, lex->analyze_stmt);
|
||||
lex->explain->print_explain_json(result, lex->analyze_stmt,
|
||||
false /* is_show_cmd */);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user