Browse Source

Merge test case of Bug#40264 to mysql-5.1-bugteam

sql/sql_cache.cc:
  Assert that results are always complete.
pull/374/head
Davi Arnaut 17 years ago
parent
commit
6157433b2a
  1. 16
      mysql-test/r/query_cache_notembedded.result
  2. 32
      mysql-test/t/query_cache_notembedded.test
  3. 3
      sql/sql_cache.cc

16
mysql-test/r/query_cache_notembedded.result

@ -346,6 +346,22 @@ id
drop table t1;
drop function f1;
set GLOBAL query_cache_size=0;
DROP TABLE IF EXISTS t1;
FLUSH STATUS;
SET GLOBAL query_cache_size=1048576;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
SHOW STATUS LIKE 'Qcache_queries_in_cache';
Variable_name Value
Qcache_queries_in_cache 0
LOCK TABLES t1 WRITE;
SELECT * FROM t1;
UNLOCK TABLES;
SHOW STATUS LIKE 'Qcache_queries_in_cache';
Variable_name Value
Qcache_queries_in_cache 0
DROP TABLE t1;
SET GLOBAL query_cache_size= default;
SET GLOBAL log_bin_trust_function_creators = 0;
DROP DATABASE IF EXISTS bug30269;
FLUSH STATUS;

32
mysql-test/t/query_cache_notembedded.test

@ -224,6 +224,38 @@ disconnect con2;
connection default;
set GLOBAL query_cache_size=0;
#
# Bug#40264: Aborted cached query causes query to hang indefinitely on next cache hit
#
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
FLUSH STATUS;
SET GLOBAL query_cache_size=1048576;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
SHOW STATUS LIKE 'Qcache_queries_in_cache';
LOCK TABLES t1 WRITE;
connect(con1,localhost,root,,);
--send SELECT * FROM t1
connection default;
let $show_type= open tables where `table`='t1' and in_use=2;
let $show_pattern= '%t1%2%';
--source include/wait_show_pattern.inc
dirty_close con1;
UNLOCK TABLES;
let $show_type= open tables where `table`='t1' and in_use=0;
let $show_pattern= '%t1%0%';
--source include/wait_show_pattern.inc
SHOW STATUS LIKE 'Qcache_queries_in_cache';
DROP TABLE t1;
SET GLOBAL query_cache_size= default;
# End of 5.0 tests
SET GLOBAL log_bin_trust_function_creators = 0;
#

3
sql/sql_cache.cc

@ -781,6 +781,9 @@ void query_cache_end_of_result(THD *thd)
if (thd->net.query_cache_query == 0)
DBUG_VOID_RETURN;
/* Ensure that only complete results are cached. */
DBUG_ASSERT(thd->main_da.is_eof());
if (thd->killed)
{
query_cache_abort(&thd->net);

Loading…
Cancel
Save