1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

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
This commit is contained in:
Varun Gupta
2017-03-15 20:15:31 +05:30
parent 122d0701f7
commit 6ac754163c
3 changed files with 53 additions and 1 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;