48
# Bug#41098: Query Cache returns wrong result with concurrent insert
51
SET @old_concurrent_insert= @@GLOBAL.concurrent_insert;
52
SET @old_query_cache_size= @@GLOBAL.query_cache_size;
55
DROP TABLE IF EXISTS t1, t2;
57
CREATE TABLE t1 (a INT);
58
CREATE TABLE t2 (a INT);
59
INSERT INTO t1 VALUES (1),(2),(3);
61
SET GLOBAL concurrent_insert= 1;
62
SET GLOBAL query_cache_size= 1024*512;
63
SET GLOBAL query_cache_type= ON;
65
connect(con1,localhost,root,,test,,);
66
connect(con2,localhost,root,,test,,);
69
--echo # Switch to connection con1
70
SET SESSION debug='+d,wait_after_query_cache_invalidate';
71
--echo # Send concurrent insert, will wait in the query cache table invalidate
72
--send INSERT INTO t1 VALUES (4)
75
--echo # Switch to connection default
76
--echo # Wait for concurrent insert to reach the debug point
78
SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
79
WHERE STATE = "wait_after_query_cache_invalidate" AND
80
INFO = "INSERT INTO t1 VALUES (4)";
81
--source include/wait_condition.inc
84
--echo # Switch to connection con2
85
--echo # Send SELECT that shouldn't be cached
89
--echo # Switch to connection default
90
--echo # Notify the concurrent insert to proceed
91
SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST
92
WHERE STATE = 'wait_after_query_cache_invalidate' INTO @thread_id;
93
KILL QUERY @thread_id;
96
--echo # Switch to connection con1
97
--echo # Gather insert result
99
SHOW STATUS LIKE "Qcache_queries_in_cache";
100
--echo # Test that it's cacheable
102
SHOW STATUS LIKE "Qcache_queries_in_cache";
109
--echo # Restore defaults
112
SET GLOBAL concurrent_insert= DEFAULT;
113
SET GLOBAL query_cache_size= DEFAULT;
114
SET GLOBAL query_cache_type= DEFAULT;