summaryrefslogtreecommitdiff
path: root/sql/sql_cache.cc
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2005-12-01 14:26:19 +0200
committerunknown <bell@sanja.is.com.ua>2005-12-01 14:26:19 +0200
commita050707b61d29dec3f39ef89f3102c6a72edb90a (patch)
tree1d52665449d39aa5645cd456959e1dd1920e2fe8 /sql/sql_cache.cc
parent598cc2db7dc5c86156929c6c2b88b2e95af427c5 (diff)
downloadmariadb-git-a050707b61d29dec3f39ef89f3102c6a72edb90a.tar.gz
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.
Diffstat (limited to 'sql/sql_cache.cc')
-rw-r--r--sql/sql_cache.cc28
1 files changed, 19 insertions, 9 deletions
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 4214c9a7c07..b40257511f7 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -956,16 +956,26 @@ 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)
- */
- 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')
{
- 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)
+ */
+ 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')
+ {
+ DBUG_PRINT("qcache", ("The statement is not a SELECT; Not cached"));
+ goto err;
+ }
}
STRUCT_LOCK(&structure_guard_mutex);