summaryrefslogtreecommitdiff
path: root/mysql-test/r/query_cache.result
diff options
context:
space:
mode:
authorunknown <thek@adventure.(none)>2007-07-12 13:29:51 +0200
committerunknown <thek@adventure.(none)>2007-07-12 13:29:51 +0200
commit30810f80b1070cbfd4579835353bb6e84fd1b233 (patch)
treeb4d8f7213751b0b2364435ee6f6c011d652235e7 /mysql-test/r/query_cache.result
parent7c70011e2165c45aa88660cb24b2b52cf67272de (diff)
downloadmariadb-git-30810f80b1070cbfd4579835353bb6e84fd1b233.tar.gz
Bug#28249 Query Cache returns wrong result with concurrent insert / certain lock
A race condition in the integration between MyISAM and the query cache code caused the query cache to fail to invalidate itself on concurrently inserted data. This patch fix this problem by using the existing handler interface which, upon each statement cache attempt, compare the size of the table as viewed from the cache writing thread and with any snap shot of the global table state. If the two sizes are different the global table size is unknown and the current statement can't be cached. mysql-test/r/query_cache.result: Added test case mysql-test/t/query_cache.test: Added test case sql/ha_myisam.cc: - Implemented handler interface for ha_myisam class to dermine if the table belonging to the currently processed statement can be cached or not. sql/ha_myisam.h: - Implemented handler interface for ha_myisam class to dermine if the table belonging to the currently processed statement can be cached or not. sql/handler.h: - Documented register_query_cache_table method in the handler interface.
Diffstat (limited to 'mysql-test/r/query_cache.result')
-rw-r--r--mysql-test/r/query_cache.result39
1 files changed, 39 insertions, 0 deletions
diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result
index 79471ee5c02..58b8aad6fc9 100644
--- a/mysql-test/r/query_cache.result
+++ b/mysql-test/r/query_cache.result
@@ -1409,3 +1409,42 @@ set GLOBAL query_cache_type=default;
set GLOBAL query_cache_limit=default;
set GLOBAL query_cache_min_res_unit=default;
set GLOBAL query_cache_size= default;
+Bug#28249 Query Cache returns wrong result with concurrent insert/ certain lock
+set GLOBAL query_cache_type=1;
+set GLOBAL query_cache_limit=10000;
+set GLOBAL query_cache_min_res_unit=0;
+set GLOBAL query_cache_size= 100000;
+flush tables;
+drop table if exists t1, t2;
+create table t1 (a int);
+create table t2 (a int);
+insert into t1 values (1),(2),(3);
+Locking table T2 with a write lock.
+lock table t2 write;
+Select blocked by write lock.
+select *, (select count(*) from t2) from t1;;
+Sleeing is ok, because selecting should be done very fast.
+Inserting into table T1.
+insert into t1 values (4);
+Unlocking the tables.
+unlock tables;
+Collecting result from previously blocked select.
+Next select should contain 4 rows, as the insert is long finished.
+select *, (select count(*) from t2) from t1;
+a (select count(*) from t2)
+1 0
+2 0
+3 0
+4 0
+reset query cache;
+select *, (select count(*) from t2) from t1;
+a (select count(*) from t2)
+1 0
+2 0
+3 0
+4 0
+drop table t1,t2;
+set GLOBAL query_cache_type=default;
+set GLOBAL query_cache_limit=default;
+set GLOBAL query_cache_min_res_unit=default;
+set GLOBAL query_cache_size=default;