1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +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

@ -33,7 +33,7 @@ drop table if exists t1;
create table t1(c1 int);
insert into t1 values(1),(10),(100);
# Prepared statements has no parameters, query caching should happen
# First, prepared statements with no parameters
prepare stmt1 from "select * from t1 where c1=10";
show status like 'Qcache_hits';
execute stmt1;
@ -113,7 +113,9 @@ show status like 'Qcache_hits';
--echo ---- switch to connection default ----
connection default;
# Prepared statement has parameters, query caching should not happen
# Query caching also works when statement has parameters
# (BUG#29318 Statements prepared with PREPARE and with one parameter don't use
# query cache)
prepare stmt1 from "select * from t1 where c1=?";
show status like 'Qcache_hits';
set @a=1;
@ -127,6 +129,12 @@ set @a=1;
prepare stmt4 from "select * from t1 where c1=?";
execute stmt4 using @a;
show status like 'Qcache_hits';
# verify that presence of user variables forbids caching
prepare stmt4 from "select @a from t1 where c1=?";
execute stmt4 using @a;
show status like 'Qcache_hits';
execute stmt4 using @a;
show status like 'Qcache_hits';
--echo ---- switch to connection default ----
connection default;