Commit 6ac75416 authored by Varun Gupta's avatar Varun Gupta

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
parent 122d0701
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
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