diff --git a/mysql-test/r/explain_slowquerylog.result b/mysql-test/r/explain_slowquerylog.result index 8ba631545c3..62c742c5932 100644 --- a/mysql-test/r/explain_slowquerylog.result +++ b/mysql-test/r/explain_slowquerylog.result @@ -20,3 +20,9 @@ Error 1146 Table 'test.nonexisting' doesn't exist SELECT 1; 1 1 +# +# MDEV-5060 Server crashes on EXPLAIN EXTENDED or EXPLAIN PARTITIONS with explain in slow_log +# +EXPLAIN PARTITIONS SELECT 1 ; +id select_type table partitions type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used diff --git a/mysql-test/t/explain_slowquerylog.test b/mysql-test/t/explain_slowquerylog.test index 09565d90931..23e31166e32 100644 --- a/mysql-test/t/explain_slowquerylog.test +++ b/mysql-test/t/explain_slowquerylog.test @@ -28,3 +28,10 @@ SHOW WARNINGS; --disconnect con1 --connection default SELECT 1; + +--echo # +--echo # MDEV-5060 Server crashes on EXPLAIN EXTENDED or EXPLAIN PARTITIONS with explain in slow_log +--echo # +EXPLAIN PARTITIONS SELECT 1 ; + + diff --git a/sql/opt_qpf.cc b/sql/opt_qpf.cc index 0f047f05ba0..152c55c98cb 100644 --- a/sql/opt_qpf.cc +++ b/sql/opt_qpf.cc @@ -122,11 +122,13 @@ int QPF_query::print_explain(select_result_sink *output, } } + bool print_qpf_query(LEX *lex, THD *thd, String *str) { return lex->query_plan_footprint->print_explain_str(thd, str); } + bool QPF_query::print_explain_str(THD *thd, String *out_str) { List fields; @@ -134,7 +136,7 @@ bool QPF_query::print_explain_str(THD *thd, String *out_str) select_result_text_buffer output_buf(thd); output_buf.send_result_set_metadata(fields, thd->lex->describe); - if (print_explain(&output_buf, 0)) + if (print_explain(&output_buf, thd->lex->describe)) return true; output_buf.save_to(out_str); return false;