diff options
author | Varun Gupta <varunraiko1803@gmail.com> | 2017-03-15 20:15:31 +0530 |
---|---|---|
committer | Varun Gupta <varunraiko1803@gmail.com> | 2017-03-15 20:15:31 +0530 |
commit | 6ac754163c417b907ce93ce2e0dd52d8d3cd35b8 (patch) | |
tree | be2cc8b9364591245161558908cefa697b090064 | |
parent | 122d0701f7b933145d068d66fe72f6959b9afb14 (diff) | |
download | mariadb-git-6ac754163c417b907ce93ce2e0dd52d8d3cd35b8.tar.gz |
MDEV-10766: Queries which start with WITH clause do not get inserted into query cache
Added conditions so that the WITH queries are also added to the query cache
-rw-r--r-- | mysql-test/r/query_cache.result | 32 | ||||
-rw-r--r-- | mysql-test/t/query_cache.test | 17 | ||||
-rw-r--r-- | sql/sql_cache.cc | 5 |
3 files changed, 53 insertions, 1 deletions
diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index d34c96cd568..276f7c470f1 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -2136,6 +2136,38 @@ Qcache_hits 1 use test; drop database `foo.bar`; End of 10.0 tests +# +# MDEV-10766 Queries which start with WITH clause do not get +# inserted into query cache +# +flush status; +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 0 +create table t1 (i int); +with cte as (select * from t1) select * from cte; +i +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 0 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 0 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +with cte as (select * from t1) select * from cte; +i +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 0 +show status like "Qcache_inserts"; +Variable_name Value +Qcache_inserts 0 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 0 +drop table t1; restore defaults SET GLOBAL query_cache_type= default; SET GLOBAL query_cache_size= default; diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test index a97b0b1c815..c354032bc36 100644 --- a/mysql-test/t/query_cache.test +++ b/mysql-test/t/query_cache.test @@ -1750,6 +1750,23 @@ drop database `foo.bar`; --echo End of 10.0 tests +--echo # +--echo # MDEV-10766 Queries which start with WITH clause do not get +--echo # inserted into query cache +--echo # +flush status; +show status like "Qcache_inserts"; +create table t1 (i int); +with cte as (select * from t1) select * from cte; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +with cte as (select * from t1) select * from cte; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +drop table t1; + --echo restore defaults SET GLOBAL query_cache_type= default; SET GLOBAL query_cache_size= default; diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 6b13dba876e..0bf83915ba8 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1828,7 +1828,10 @@ Query_cache::send_result_to_client(THD *thd, char *org_sql, uint query_length) } 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')) + my_toupper(system_charset_info, sql[2]) != 'L') && + (my_toupper(system_charset_info, sql[0]) != 'W' || + my_toupper(system_charset_info, sql[1]) != 'I' || + my_toupper(system_charset_info, sql[2]) != 'T')) { DBUG_PRINT("qcache", ("The statement is not a SELECT; Not cached")); goto err; |