summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <tsmith/tim@siva.hindu.god>2006-10-12 17:10:34 -0600
committerunknown <tsmith/tim@siva.hindu.god>2006-10-12 17:10:34 -0600
commit99d42667d68a6ad5c52c6a24029477687b44f45d (patch)
treec29fede3b0fb5cd2a1b42a5af37bd61bb10b6289 /sql
parente9b7cc09e5ab9ee8d4b6a879a7ed2282f45c6f8a (diff)
downloadmariadb-git-99d42667d68a6ad5c52c6a24029477687b44f45d.tar.gz
Bug #19764: SHOW commands end up in the slow log as table scans
Do not consider SHOW commands slow queries, just because they don't use proper indexes. This bug fix is not needed in 5.1, and the code changes will be null merged. However, the test cases will be propogated up to 5.1. mysql-test/t/show_check-master.opt: Rename: BitKeeper/deleted/.del-show_check-master.opt -> mysql-test/t/show_check-master.opt mysql-test/r/ps.result: Add test case for bug 19764 mysql-test/r/show_check.result: Add test case for bug 19764 mysql-test/r/union.result: Adjust test case results based on bug #19764 changes mysql-test/t/ps.test: Add test case for bug 19764 mysql-test/t/show_check.test: Add test case for bug 19764 sql/sql_parse.cc: Do not log SHOW commands as slow queries just because they don't use indexes. sql/sql_prepare.cc: Save stmt_backup.lex->orig_sql_command for use in log_slow_statement() mysql-test/t/ps-master.opt: Add log-slow-queries and --log-queries-not-using indexes, to test bug #19764
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_parse.cc6
-rw-r--r--sql/sql_prepare.cc6
2 files changed, 10 insertions, 2 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 18d048df393..fdbfa71e141 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 32f0ca6859d..e8025121eb3 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -2909,6 +2909,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