diff --git a/mysql-test/r/log_slow.result b/mysql-test/r/log_slow.result index 75e92e7a0b5..318dfa7568d 100644 --- a/mysql-test/r/log_slow.result +++ b/mysql-test/r/log_slow.result @@ -56,5 +56,18 @@ insert_id int(11) NO NULL server_id int(10) unsigned NO NULL sql_text mediumtext NO NULL flush slow logs; +set long_query_time=0.1; +set log_slow_filter=''; +set global slow_query_log=1; +set global log_output='TABLE'; +select sleep(0.5); +sleep(0.5) +0 +select count(*) FROM mysql.slow_log; +count(*) +1 +truncate mysql.slow_log; +set @@long_query_time=default; +set global slow_query_log=default; set @@log_slow_filter=default; set @@log_slow_verbosity=default; diff --git a/mysql-test/t/log_slow.test b/mysql-test/t/log_slow.test index af8a948d318..54f56e1bdfc 100644 --- a/mysql-test/t/log_slow.test +++ b/mysql-test/t/log_slow.test @@ -42,7 +42,18 @@ show fields from mysql.slow_log; flush slow logs; -# Reset used variables +# MDEV-4206 (empty filter should be no filter) +set long_query_time=0.1; +set log_slow_filter=''; +set global slow_query_log=1; +set global log_output='TABLE'; +select sleep(0.5); +select count(*) FROM mysql.slow_log; +truncate mysql.slow_log; + +# Reset used variables +set @@long_query_time=default; +set global slow_query_log=default; set @@log_slow_filter=default; set @@log_slow_verbosity=default; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 989f1ed66de..05957197817 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1497,7 +1497,8 @@ void log_slow_statement(THD *thd) /* Follow the slow log filter configuration. */ if (!thd->enable_slow_log || - !(thd->variables.log_slow_filter & thd->query_plan_flags)) + (thd->variables.log_slow_filter + && !(thd->variables.log_slow_filter & thd->query_plan_flags))) DBUG_VOID_RETURN; if (((thd->server_status & SERVER_QUERY_WAS_SLOW) ||