summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2005-12-01 14:38:29 +0200
committerunknown <bell@sanja.is.com.ua>2005-12-01 14:38:29 +0200
commitf0b33dd9e452565634e98aeeea23ff312b46d1f6 (patch)
tree2fdb203e8cc312708738a9c8aab02d81cd9ac837
parent483e04b2d616953b8e02b1017fc6fcfaa1fc93ac (diff)
parenta050707b61d29dec3f39ef89f3102c6a72edb90a (diff)
downloadmariadb-git-f0b33dd9e452565634e98aeeea23ff312b46d1f6.tar.gz
Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.1
into sanja.is.com.ua:/home/bell/mysql/bk/work-merge1-5.0 configure.in: merge mysql-test/r/query_cache.result: merge mysql-test/t/query_cache.test: merge sql/sql_cache.cc: merge
-rw-r--r--mysql-test/r/query_cache.result25
-rw-r--r--mysql-test/t/query_cache.test15
-rw-r--r--sql/sql_cache.cc38
3 files changed, 64 insertions, 14 deletions
diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result
index 97d14b2be3a..c4521b4a71e 100644
--- a/mysql-test/r/query_cache.result
+++ b/mysql-test/r/query_cache.result
@@ -850,6 +850,31 @@ group_concat(a)
set group_concat_max_len=default;
drop table t1;
create table t1 (a int);
+flush status;
+(select a from t1) union (select a from t1);
+a
+show status like "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 1
+show status like "Qcache_inserts";
+Variable_name Value
+Qcache_inserts 1
+show status like "Qcache_hits";
+Variable_name Value
+Qcache_hits 0
+(select a from t1) union (select a from t1);
+a
+show status like "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 1
+show status like "Qcache_inserts";
+Variable_name Value
+Qcache_inserts 1
+show status like "Qcache_hits";
+Variable_name Value
+Qcache_hits 1
+drop table t1;
+create table t1 (a int);
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test
index 646151a5aae..d83f84661d5 100644
--- a/mysql-test/t/query_cache.test
+++ b/mysql-test/t/query_cache.test
@@ -743,6 +743,21 @@ show status like "Qcache_hits";
drop table t1;
#
+# BUG#14652: Queries with leading '(' characters.
+#
+create table t1 (a int);
+flush status;
+(select a from t1) union (select a from t1);
+show status like "Qcache_queries_in_cache";
+show status like "Qcache_inserts";
+show status like "Qcache_hits";
+(select a from t1) union (select a from t1);
+show status like "Qcache_queries_in_cache";
+show status like "Qcache_inserts";
+show status like "Qcache_hits";
+drop table t1;
+
+#
# SP cursors and selects with query cache (BUG#9715)
#
create table t1 (a int);
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 24ab27c587d..0a01832bb39 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -977,21 +977,31 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
goto err;
}
- /*
- Test if the query is a SELECT
- (pre-space is removed in dispatch_command).
-
- First '/' looks like comment before command it is not
- frequently appeared in real lihe, consequently we can
- check all such queries, too.
- */
- if ((my_toupper(system_charset_info, sql[0]) != 'S' ||
- my_toupper(system_charset_info, sql[1]) != 'E' ||
- my_toupper(system_charset_info,sql[2]) !='L') &&
- sql[0] != '/')
{
- DBUG_PRINT("qcache", ("The statement is not a SELECT; Not cached"));
- goto err;
+ uint i= 0;
+ /*
+ Skip '(' characters in queries like following:
+ (select a from t1) union (select a from t1);
+ */
+ while (sql[i]=='(')
+ i++;
+
+ /*
+ Test if the query is a SELECT
+ (pre-space is removed in dispatch_command)
+
+ First '/' looks like comment before command it is not
+ frequently appeared in real lihe, consequently we can
+ check all such queries, too.
+ */
+ if ((my_toupper(system_charset_info, sql[i]) != 'S' ||
+ my_toupper(system_charset_info, sql[i + 1]) != 'E' ||
+ my_toupper(system_charset_info, sql[i + 2]) != 'L') &&
+ sql[i] != '/')
+ {
+ DBUG_PRINT("qcache", ("The statement is not a SELECT; Not cached"));
+ goto err;
+ }
}
STRUCT_LOCK(&structure_guard_mutex);