From 1a8ac44cff9f2b8103bf47d058e853a4af9d344f Mon Sep 17 00:00:00 2001 From: "joerg@mysql.com" <> Date: Wed, 30 Nov 2005 21:50:09 +0100 Subject: [PATCH 1/2] Raise the version number (as 4.1.16 has been cloned). --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 41475ffcd4a..9afd2034796 100644 --- a/configure.in +++ b/configure.in @@ -5,7 +5,7 @@ AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! # remember to also change ndb version below and update version.c in ndb -AM_INIT_AUTOMAKE(mysql, 4.1.16) +AM_INIT_AUTOMAKE(mysql, 4.1.17) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 @@ -16,7 +16,7 @@ SHARED_LIB_VERSION=14:0:0 # ndb version NDB_VERSION_MAJOR=4 NDB_VERSION_MINOR=1 -NDB_VERSION_BUILD=16 +NDB_VERSION_BUILD=17 NDB_VERSION_STATUS="" # Set all version vars based on $VERSION. How do we do this more elegant ? From 12d1bf12315f5e25ea36453a9df86925e18c9d42 Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Thu, 1 Dec 2005 14:26:19 +0200 Subject: [PATCH 2/2] We should skip beggining '(' characters when test query on possibility to be in the query cache. (BUG#14652) --- mysql-test/r/query_cache.result | 25 +++++++++++++++++++++++++ mysql-test/t/query_cache.test | 15 +++++++++++++++ sql/sql_cache.cc | 28 +++++++++++++++++++--------- 3 files changed, 59 insertions(+), 9 deletions(-) diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index ed87e2be2b4..24363ea27ab 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -982,4 +982,29 @@ show status like "Qcache_hits"; Variable_name Value Qcache_hits 1 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; diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test index d08dc5fb352..3140739309e 100644 --- a/mysql-test/t/query_cache.test +++ b/mysql-test/t/query_cache.test @@ -712,6 +712,21 @@ show status like "Qcache_inserts"; 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; + set GLOBAL query_cache_size=0; # End of 4.1 tests 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);