summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2019-02-27 13:14:31 +0400
committerAlexander Barkov <bar@mariadb.com>2019-03-04 13:49:15 +0400
commit19df45a705a48f5c8c21af0814cb5be7d816977b (patch)
treef4c4f13df3ff1bad07639e2e1be2ddc386b796bc /mysql-test
parentf2e1451740d417f1c9ea8626d937fbcacc91bb55 (diff)
downloadmariadb-git-19df45a705a48f5c8c21af0814cb5be7d816977b.tar.gz
MDEV-18333 Slow_queries count doesn't increase when slow_query_log is turned off
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/log_slow.result37
-rw-r--r--mysql-test/t/log_slow.test40
2 files changed, 77 insertions, 0 deletions
diff --git a/mysql-test/r/log_slow.result b/mysql-test/r/log_slow.result
index 02e04cfbb2d..c50130a7b7a 100644
--- a/mysql-test/r/log_slow.result
+++ b/mysql-test/r/log_slow.result
@@ -76,3 +76,40 @@ set @@log_slow_filter=default;
set @@log_slow_verbosity=default;
set global log_output= default;
truncate mysql.slow_log;
+#
+# MDEV-18333 Slow_queries count doesn't increase when slow_query_log is turned off
+#
+SET SESSION slow_query_log=OFF;
+SET GLOBAL slow_query_log=OFF;
+SET long_query_time=0.1;
+# Although this query is disallowed by slow_query_log, it should still increment Slow_queries
+SELECT VARIABLE_VALUE INTO @global_slow_queries
+FROM INFORMATION_SCHEMA.GLOBAL_STATUS
+WHERE VARIABLE_NAME='SLOW_QUERIES';
+SELECT sleep(0.2) INTO @tmp FROM DUAL;
+SELECT
+CAST(VARIABLE_VALUE AS UNSIGNED)-@global_slow_queries AS Slow_queries_increment
+FROM
+INFORMATION_SCHEMA.GLOBAL_STATUS
+WHERE
+VARIABLE_NAME='SLOW_QUERIES';
+Slow_queries_increment
+1
+# Although this query is disallowed by log_slow_filter, it should still increment Slow_queries
+SET log_slow_filter=filesort;
+SELECT sleep(0.2) INTO @tmp FROM DUAL;
+SELECT VARIABLE_VALUE INTO @global_slow_queries
+FROM INFORMATION_SCHEMA.GLOBAL_STATUS
+WHERE VARIABLE_NAME='SLOW_QUERIES';
+SELECT sleep(0.2) INTO @tmp FROM DUAL;
+SELECT
+CAST(VARIABLE_VALUE AS UNSIGNED)-@global_slow_queries AS Slow_queries_increment
+FROM
+INFORMATION_SCHEMA.GLOBAL_STATUS
+WHERE
+VARIABLE_NAME='SLOW_QUERIES';
+Slow_queries_increment
+1
+SET log_slow_filter=DEFAULT;
+SET @@long_query_time=default;
+SET GLOBAL slow_query_log= @org_slow_query_log;
diff --git a/mysql-test/t/log_slow.test b/mysql-test/t/log_slow.test
index 56e35bd5a20..edb1865b5ae 100644
--- a/mysql-test/t/log_slow.test
+++ b/mysql-test/t/log_slow.test
@@ -58,3 +58,43 @@ set @@log_slow_filter=default;
set @@log_slow_verbosity=default;
set global log_output= default;
truncate mysql.slow_log;
+
+--echo #
+--echo # MDEV-18333 Slow_queries count doesn't increase when slow_query_log is turned off
+--echo #
+
+SET SESSION slow_query_log=OFF;
+SET GLOBAL slow_query_log=OFF;
+SET long_query_time=0.1;
+
+--echo # Although this query is disallowed by slow_query_log, it should still increment Slow_queries
+
+SELECT VARIABLE_VALUE INTO @global_slow_queries
+ FROM INFORMATION_SCHEMA.GLOBAL_STATUS
+ WHERE VARIABLE_NAME='SLOW_QUERIES';
+SELECT sleep(0.2) INTO @tmp FROM DUAL;
+SELECT
+ CAST(VARIABLE_VALUE AS UNSIGNED)-@global_slow_queries AS Slow_queries_increment
+ FROM
+ INFORMATION_SCHEMA.GLOBAL_STATUS
+ WHERE
+ VARIABLE_NAME='SLOW_QUERIES';
+
+--echo # Although this query is disallowed by log_slow_filter, it should still increment Slow_queries
+
+SET log_slow_filter=filesort;
+SELECT sleep(0.2) INTO @tmp FROM DUAL;
+SELECT VARIABLE_VALUE INTO @global_slow_queries
+ FROM INFORMATION_SCHEMA.GLOBAL_STATUS
+ WHERE VARIABLE_NAME='SLOW_QUERIES';
+SELECT sleep(0.2) INTO @tmp FROM DUAL;
+SELECT
+ CAST(VARIABLE_VALUE AS UNSIGNED)-@global_slow_queries AS Slow_queries_increment
+ FROM
+ INFORMATION_SCHEMA.GLOBAL_STATUS
+ WHERE
+ VARIABLE_NAME='SLOW_QUERIES';
+SET log_slow_filter=DEFAULT;
+
+SET @@long_query_time=default;
+SET GLOBAL slow_query_log= @org_slow_query_log;