Commit ccca3394 authored by Sergey Petrunya's avatar Sergey Petrunya

MDEV-5047 virtual THD::~THD(): Assertion `status_var.memory_used == 0' fails

- Don't forget to delete the query plan footprint when 
  the query wasn't printed into slow query log for some reason
- ALso removed some garbage code.
parent d998a163
...@@ -9,3 +9,14 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -9,3 +9,14 @@ id select_type table type possible_keys key key_len ref rows Extra
# #
set autocommit=1; set autocommit=1;
drop table t0; drop table t0;
#
# MDEV-5047 virtual THD::~THD(): Assertion `status_var.memory_used == 0' fails on disconnect
#
ALTER TABLE nonexisting ENABLE KEYS;
ERROR 42S02: Table 'test.nonexisting' doesn't exist
SHOW WARNINGS;
Level Code Message
Error 1146 Table 'test.nonexisting' doesn't exist
SELECT 1;
1
1
...@@ -16,5 +16,15 @@ explain select * from t0 where a < 3; ...@@ -16,5 +16,15 @@ explain select * from t0 where a < 3;
--echo # MDEV-5045: Server crashes in QPF_query::print_explain with log_slow_verbosity='query_plan,explain' --echo # MDEV-5045: Server crashes in QPF_query::print_explain with log_slow_verbosity='query_plan,explain'
--echo # --echo #
set autocommit=1; set autocommit=1;
drop table t0; drop table t0;
--echo #
--echo # MDEV-5047 virtual THD::~THD(): Assertion `status_var.memory_used == 0' fails on disconnect
--echo #
--connect (con1,localhost,root,,)
--error ER_NO_SUCH_TABLE
ALTER TABLE nonexisting ENABLE KEYS;
SHOW WARNINGS;
--disconnect con1
--connection default
SELECT 1;
...@@ -1525,6 +1525,10 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -1525,6 +1525,10 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
} }
/*
@note
This function must call delete_qpf_query().
*/
void log_slow_statement(THD *thd) void log_slow_statement(THD *thd)
{ {
DBUG_ENTER("log_slow_statement"); DBUG_ENTER("log_slow_statement");
...@@ -1543,7 +1547,10 @@ void log_slow_statement(THD *thd) ...@@ -1543,7 +1547,10 @@ void log_slow_statement(THD *thd)
if (!thd->enable_slow_log || if (!thd->enable_slow_log ||
(thd->variables.log_slow_filter (thd->variables.log_slow_filter
&& !(thd->variables.log_slow_filter & thd->query_plan_flags))) && !(thd->variables.log_slow_filter & thd->query_plan_flags)))
{
delete_qpf_query(thd->lex);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
}
if (((thd->server_status & SERVER_QUERY_WAS_SLOW) || if (((thd->server_status & SERVER_QUERY_WAS_SLOW) ||
((thd->server_status & ((thd->server_status &
...@@ -4799,13 +4806,7 @@ case SQLCOM_PREPARE: ...@@ -4799,13 +4806,7 @@ case SQLCOM_PREPARE:
#endif #endif
} }
lex->unit.cleanup(); lex->unit.cleanup();
//psergey-todo: print EXPLAIN here? After the above JOIN::cleanup calls?
// how do we print EXPLAIN extended, then?
if (lex->describe)
{
DBUG_ASSERT(lex->query_plan_footprint);
///..
}
/* Free tables */ /* Free tables */
thd_proc_info(thd, "closing tables"); thd_proc_info(thd, "closing tables");
close_thread_tables(thd); close_thread_tables(thd);
......
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