summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <tsmith/tim@siva.hindu.god>2006-10-16 20:15:14 -0600
committerunknown <tsmith/tim@siva.hindu.god>2006-10-16 20:15:14 -0600
commit1e8c450dea260fb3827f0d79a214c969b4abd571 (patch)
tree3f89b2096b71b6cfb47a48455bc0cdfe62f65634
parent4771fc36bca491b0e403a6f3ffe53e8973577bd8 (diff)
parent99d42667d68a6ad5c52c6a24029477687b44f45d (diff)
downloadmariadb-git-1e8c450dea260fb3827f0d79a214c969b4abd571.tar.gz
Merge siva.hindu.god:/usr/home/tim/m/bk/b19764/50
into siva.hindu.god:/usr/home/tim/m/bk/tmp/mrgOct16/50 sql/sql_parse.cc: Auto merged sql/sql_prepare.cc: Auto merged mysql-test/r/ps.result: Manual merge mysql-test/t/ps.test: Manual merge
-rw-r--r--mysql-test/r/ps.result17
-rw-r--r--mysql-test/r/show_check.result15
-rw-r--r--mysql-test/r/union.result8
-rw-r--r--mysql-test/t/ps-master.opt1
-rw-r--r--mysql-test/t/ps.test14
-rw-r--r--mysql-test/t/show_check-master.opt1
-rw-r--r--mysql-test/t/show_check.test12
-rw-r--r--sql/sql_parse.cc6
-rw-r--r--sql/sql_prepare.cc6
9 files changed, 74 insertions, 6 deletions
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index 048c3ae46d3..ae7784db86b 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -1379,4 +1379,21 @@ i
1
DEALLOCATE PREPARE stmt;
DROP TABLE t1, t2;
+flush status;
+prepare sq from 'show status like "slow_queries"';
+execute sq;
+Variable_name Value
+Slow_queries 0
+prepare no_index from 'select 1 from information_schema.tables limit 1';
+execute sq;
+Variable_name Value
+Slow_queries 0
+execute no_index;
+1
+1
+execute sq;
+Variable_name Value
+Slow_queries 1
+deallocate prepare no_index;
+deallocate prepare sq;
End of 5.0 tests.
diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result
index 762019be313..1ced624b196 100644
--- a/mysql-test/r/show_check.result
+++ b/mysql-test/r/show_check.result
@@ -630,4 +630,19 @@ SHOW TABLES FROM no_such_database;
ERROR 42000: Unknown database 'no_such_database'
SHOW COLUMNS FROM no_such_table;
ERROR 42S02: Table 'test.no_such_table' doesn't exist
+flush status;
+show status like 'slow_queries';
+Variable_name Value
+Slow_queries 0
+show tables;
+Tables_in_test
+show status like 'slow_queries';
+Variable_name Value
+Slow_queries 0
+select 1 from information_schema.tables limit 1;
+1
+1
+show status like 'slow_queries';
+Variable_name Value
+Slow_queries 1
End of 5.0 tests
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index 12463658bf9..dc174e35c8f 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -836,27 +836,27 @@ count(*)
26
show status like 'Slow_queries';
Variable_name Value
-Slow_queries 1
+Slow_queries 0
select count(*) from t1 where b=13;
count(*)
10
show status like 'Slow_queries';
Variable_name Value
-Slow_queries 3
+Slow_queries 1
select count(*) from t1 where b=13 union select count(*) from t1 where a=7;
count(*)
10
26
show status like 'Slow_queries';
Variable_name Value
-Slow_queries 5
+Slow_queries 2
select count(*) from t1 where a=7 union select count(*) from t1 where b=13;
count(*)
26
10
show status like 'Slow_queries';
Variable_name Value
-Slow_queries 7
+Slow_queries 3
flush status;
select a from t1 where b not in (1,2,3) union select a from t1 where b not in (4,5,6);
a
diff --git a/mysql-test/t/ps-master.opt b/mysql-test/t/ps-master.opt
new file mode 100644
index 00000000000..3eb98fc3d6b
--- /dev/null
+++ b/mysql-test/t/ps-master.opt
@@ -0,0 +1 @@
+--log-slow-queries --log-long-format --log-queries-not-using-indexes
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index 78262eb617c..71fcaf4f4e5 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -1437,4 +1437,18 @@ DEALLOCATE PREPARE stmt;
DROP TABLE t1, t2;
+#
+# Bug 19764: SHOW commands end up in the slow log as table scans
+#
+
+flush status;
+prepare sq from 'show status like "slow_queries"';
+execute sq;
+prepare no_index from 'select 1 from information_schema.tables limit 1';
+execute sq;
+execute no_index;
+execute sq;
+deallocate prepare no_index;
+deallocate prepare sq;
+
--echo End of 5.0 tests.
diff --git a/mysql-test/t/show_check-master.opt b/mysql-test/t/show_check-master.opt
new file mode 100644
index 00000000000..3eb98fc3d6b
--- /dev/null
+++ b/mysql-test/t/show_check-master.opt
@@ -0,0 +1 @@
+--log-slow-queries --log-long-format --log-queries-not-using-indexes
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index 07426193dcf..849be577893 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -507,4 +507,16 @@ SHOW TABLES FROM no_such_database;
SHOW COLUMNS FROM no_such_table;
+#
+# Bug #19764: SHOW commands end up in the slow log as table scans
+#
+flush status;
+show status like 'slow_queries';
+show tables;
+show status like 'slow_queries';
+# Table scan query, to ensure that slow_queries does still get incremented
+# (mysqld is started with --log-queries-not-using-indexes)
+select 1 from information_schema.tables limit 1;
+show status like 'slow_queries';
+
--echo End of 5.0 tests
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index febe256807a..0e0436af8d5 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2159,9 +2159,11 @@ void log_slow_statement(THD *thd)
if ((ulong) (thd->start_time - thd->time_after_lock) >
thd->variables.long_query_time ||
- ((thd->server_status &
+ (thd->server_status &
(SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
- (specialflag & SPECIAL_LOG_QUERIES_NOT_USING_INDEXES)))
+ (specialflag & SPECIAL_LOG_QUERIES_NOT_USING_INDEXES) &&
+ /* == SQLCOM_END unless this is a SHOW command */
+ thd->lex->orig_sql_command == SQLCOM_END)
{
thd->status_var.long_query_count++;
mysql_slow_log.write(thd, thd->query, thd->query_length, start_of_query);
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 9e321411863..5a2e2f7d419 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -2930,6 +2930,12 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
stmt_backup.query_length= thd->query_length;
/*
+ Save orig_sql_command as we use it to disable slow logging for SHOW
+ commands (see log_slow_statement()).
+ */
+ stmt_backup.lex->orig_sql_command= thd->lex->orig_sql_command;
+
+ /*
At first execution of prepared statement we may perform logical
transformations of the query tree. Such changes should be performed
on the parse tree of current prepared statement and new items should