Commit a050707b authored by unknown's avatar unknown

We should skip beggining '(' characters when test query on possibility

to be in the query cache. (BUG#14652)


mysql-test/r/query_cache.result:
  BUG#14652 test suite.
mysql-test/t/query_cache.test:
  BUG#14652 test suite.
sql/sql_cache.cc:
  We should skip beggining '(' characters when test query on possibility
  to be in the query cache.
parent 598cc2db
...@@ -982,4 +982,29 @@ show status like "Qcache_hits"; ...@@ -982,4 +982,29 @@ show status like "Qcache_hits";
Variable_name Value Variable_name Value
Qcache_hits 1 Qcache_hits 1
drop table t1; 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;
set GLOBAL query_cache_size=0; set GLOBAL query_cache_size=0;
...@@ -712,6 +712,21 @@ show status like "Qcache_inserts"; ...@@ -712,6 +712,21 @@ show status like "Qcache_inserts";
show status like "Qcache_hits"; show status like "Qcache_hits";
drop table t1; 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;
set GLOBAL query_cache_size=0; set GLOBAL query_cache_size=0;
# End of 4.1 tests # End of 4.1 tests
...@@ -956,17 +956,27 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length) ...@@ -956,17 +956,27 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
goto err; 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 Test if the query is a SELECT
(pre-space is removed in dispatch_command) (pre-space is removed in dispatch_command)
*/ */
if (my_toupper(system_charset_info, sql[0]) != 'S' || if (my_toupper(system_charset_info, sql[i]) != 'S' ||
my_toupper(system_charset_info, sql[1]) != 'E' || my_toupper(system_charset_info, sql[i + 1]) != 'E' ||
my_toupper(system_charset_info,sql[2]) !='L') my_toupper(system_charset_info, sql[i + 2]) != 'L')
{ {
DBUG_PRINT("qcache", ("The statement is not a SELECT; Not cached")); DBUG_PRINT("qcache", ("The statement is not a SELECT; Not cached"));
goto err; goto err;
} }
}
STRUCT_LOCK(&structure_guard_mutex); STRUCT_LOCK(&structure_guard_mutex);
if (query_cache_size == 0) if (query_cache_size == 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment