1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

Fix for BUG#29318 "Statements prepared with PREPARE and with one

parameter don't use query cache"
Thanks to the fix of BUG#26842, statements prepared with SQL PREPARE
and having parameters can now use the query cache.


mysql-test/include/query_cache_sql_prepare.inc:
  now, statements prepared with SQL PREPARE use the query cache even
  when they have parameters.
mysql-test/r/query_cache_ps_no_prot.result:
  updated result: we see caching happened.
mysql-test/r/query_cache_ps_ps_prot.result:
  updated result: we see caching happened
sql/sql_prepare.cc:
  query expansion does not insert user variables' references anymore,
  it now inserts parameters' values (BUG#26842's fix did this);
  so we can use the query cache.
This commit is contained in:
unknown
2007-06-23 19:16:51 +02:00
parent a50a88e29c
commit ba7e22dbe4
4 changed files with 212 additions and 190 deletions

View File

@@ -144,7 +144,7 @@ c1
1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 14
Qcache_hits 15
---- switch to connection con1 ----
set @a=1;
prepare stmt4 from "select * from t1 where c1=?";
@@ -153,64 +153,38 @@ c1
1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 14
Qcache_hits 16
prepare stmt4 from "select @a from t1 where c1=?";
execute stmt4 using @a;
@a
1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 16
execute stmt4 using @a;
@a
1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 16
---- switch to connection default ----
prepare stmt1 from "select * from t1 where c1=10";
set global query_cache_size=0;
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 14
Qcache_hits 16
execute stmt1;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 14
Qcache_hits 16
execute stmt1;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 14
execute stmt1;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 14
---- switch to connection con1 ----
execute stmt3;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 14
execute stmt3;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 14
execute stmt3;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 14
---- switch to connection default ----
set global query_cache_size=100000;
execute stmt1;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 14
execute stmt1;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 15
Qcache_hits 16
execute stmt1;
c1
10
@@ -223,42 +197,39 @@ c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 17
Qcache_hits 16
execute stmt3;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 16
execute stmt3;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 16
---- switch to connection default ----
set global query_cache_size=100000;
execute stmt1;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 16
execute stmt1;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 17
execute stmt1;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 18
execute stmt3;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
---- switch to connection default ----
set global query_cache_size=0;
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
execute stmt1;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
execute stmt1;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
execute stmt1;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
---- switch to connection con1 ----
execute stmt3;
c1
@@ -271,13 +242,55 @@ c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
Qcache_hits 20
execute stmt3;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
Qcache_hits 21
---- switch to connection default ----
set global query_cache_size=0;
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 21
execute stmt1;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 21
execute stmt1;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 21
execute stmt1;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 21
---- switch to connection con1 ----
execute stmt3;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 21
execute stmt3;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 21
execute stmt3;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 21
---- switch to connection default ----
set global query_cache_size=0;
prepare stmt1 from "select * from t1 where c1=10";
@@ -287,75 +300,75 @@ prepare stmt3 from "select * from t1 where c1=10";
set global query_cache_size=100000;
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
Qcache_hits 21
execute stmt1;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
Qcache_hits 21
execute stmt1;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
Qcache_hits 21
execute stmt1;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
Qcache_hits 21
---- switch to connection con1 ----
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
Qcache_hits 21
execute stmt3;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
Qcache_hits 21
execute stmt3;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
Qcache_hits 21
execute stmt3;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
Qcache_hits 21
---- switch to connection default ----
set global query_cache_size=0;
prepare stmt1 from "select * from t1 where c1=?";
set global query_cache_size=100000;
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
Qcache_hits 21
set @a=1;
execute stmt1 using @a;
c1
1
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
Qcache_hits 21
set @a=100;
execute stmt1 using @a;
c1
100
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
Qcache_hits 21
set @a=10;
execute stmt1 using @a;
c1
10
show status like 'Qcache_hits';
Variable_name Value
Qcache_hits 19
Qcache_hits 21
drop table t1;
---- disconnect connection con1 ----
set @@global.query_cache_size=@initial_query_cache_size;