From 2a80ea1a8ffbeb7819dcc3262bdefdecd8165d8f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 31 Mar 2005 19:17:45 -0800 Subject: Fix crash in embedded server due to incorrect storage of results in the query cache. (Bug #9549) libmysqld/emb_qcache.h: Fix Querycache_stream::use_next_block() to actually use the next block and mark blocks as used when it writes to them. mysql-test/r/query_cache.result: Update results. mysql-test/t/query_cache.test: Add new regression test. libmysqld/emb_qcache.cc: Fix calls to use_next_block() to indicate whether we are writing to the next block or not. sql/sql_cache.cc: Initialize the first block properly when storing a result in the embedded server. --- mysql-test/t/query_cache.test | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'mysql-test/t/query_cache.test') diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test index b0148a689af..b287e71d6ae 100644 --- a/mysql-test/t/query_cache.test +++ b/mysql-test/t/query_cache.test @@ -684,4 +684,49 @@ repair table t1; show status like 'qcache_queries_in_cache'; drop table t1; +# Bug #9549: Make sure cached queries that span more than one cache block +# are handled properly in the embedded server. + +# We just want a small query cache, so we can fragment it easily +set GLOBAL query_cache_size=64*1024; +# This actually gives us a usable cache size of about 48K + +# Each table is about 14K +create table t1 (a text); +insert into t1 values (repeat('abcdefghijklmnopqrstuvwxyz', 550)); +create table t2 (a text); +insert into t2 values (repeat('ijklmnopqrstuvwxyzabcdefgh', 550)); + +# Load a query from each table into the query cache +--disable_result_log +select a from t1; # Q1 +select a from t2; # Q2 +--enable_result_log +show status like 'Qcache_%_blocks'; + +# Now the cache looks like (14K for Q1)(14K for Q2)(20K free) + +# Flush Q1 from the cache by adding an out-of-order chunk to t1 +insert into t1 select reverse(a) from t1; +show status like 'Qcache_%_blocks'; + +# Now the cache looks like (14K free)(14K for Q2)(20K free) + +# Load our new data into the query cache +--disable_result_log +select a from t1; # Q3 +--enable_result_log +show status like 'Qcache_%_blocks'; + +# Now the cache should be like (14K for Q3)(14K for Q2)(14K for Q3)(6K free) + +# Note that Q3 is split across two chunks! + +# Load Q3 from the cache, and actually pay attention to the results +select a from t1; + +flush query cache; + +drop table t1, t2; + set GLOBAL query_cache_size=0; -- cgit v1.2.1