mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / t / query_cache_notembedded.test
blob095d47f5bdf47336e7a5ad6eb7fe1a06dcffacca
1 -- source include/have_query_cache.inc
2 -- source include/not_embedded.inc
4 # Save the initial number of concurrent sessions
5 --source include/count_sessions.inc
9 # Tests with query cache
11 set GLOBAL query_cache_size=1355776;
13 # Reset query cache variables.
15 flush query cache; # This crashed in some versions
16 flush query cache; # This crashed in some versions
17 reset query cache;
18 flush status;
19 --disable_warnings
20 drop table if exists t1, t2, t3, t11, t21;
21 --enable_warnings
23 # FLUSH QUERY CACHE
25 create table t1 (a int not null);
26 insert into t1 values (1),(2),(3);
27 create table t2 (a int not null);
28 insert into t2 values (1),(2),(3);
29 select * from t1;
30 select * from t2;
31 insert into t1 values (4);
32 show status like "Qcache_free_blocks";
33 flush query cache;
34 show status like "Qcache_free_blocks";
35 drop table t1, t2;
36 # With join results...
37 create table t1 (a text not null);
38 create table t11 (a text not null);
39 create table t2 (a text not null);
40 create table t21 (a text not null);
41 create table t3 (a text not null);
42 insert into t1 values("1111111111111111111111111111111111111111111111111111");
43 insert into t2 select * from t1;
44 insert into t1 select * from t2;
45 insert into t2 select * from t1;
46 insert into t1 select * from t2;
47 insert into t2 select * from t1;
48 insert into t1 select * from t2;
49 insert into t2 select * from t1;
50 insert into t1 select * from t2;
51 insert into t2 select * from t1;
52 insert into t1 select * from t2;
53 insert into t2 select * from t1;
54 insert into t1 select * from t2;
55 insert into t2 select * from t1;
56 insert into t1 select * from t2;
57 insert into t2 select * from t1;
58 # t11 and t21 must be over 4Kb (QUERY_CACHE_MIN_RESULT_DATA_SIZE)
59 insert into t11 select * from t1;
60 insert into t21 select * from t1;
61 insert into t1 select * from t2;
62 insert into t2 select * from t1;
63 insert into t1 select * from t2;
64 #results of t3 must  be > 0.5Mb
65 insert into t3 select * from t1;
66 insert into t3 select * from t2;
67 insert into t3 select * from t1;
68 disable_result_log;
69 select * from t11;
70 select * from t21;
71 enable_result_log;
72 show status like "Qcache_total_blocks";
73 show status like "Qcache_free_blocks";
74 disable_result_log;
75 insert into t11 values("");
76 select * from t3;
77 enable_result_log;
78 show status like "Qcache_total_blocks";
79 show status like "Qcache_free_blocks";
80 flush query cache;
81 show status like "Qcache_total_blocks";
82 show status like "Qcache_free_blocks";
83 drop table t1, t2, t3, t11, t21;
86 # do not use QC if tables locked (Bug#12385)
88 connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
89 connection root;
90 CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY AUTO_INCREMENT ) ENGINE =
91 MyISAM;
92 LOCK TABLE t1 READ LOCAL;
93 connect (root2,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
94 connection root2;
95 INSERT INTO t1 VALUES (), (), ();
96 connection root;
97 SELECT * FROM t1;
98 connection root2;
99 SELECT * FROM t1;
100 connection root;
101 SELECT * FROM t1;
102 drop table t1;
103 connection default;
104 disconnect root;
105 disconnect root2;
108 # query in QC from normal execution and SP (Bug#6897)
109 # improved to also test Bug#3583 and Bug#12990
111 flush query cache;
112 reset query cache;
113 flush status;
114 delimiter //;
115 create table t1 (s1 int)//
116 create procedure f1 () begin
117 select sql_cache * from t1;
118 select sql_cache * from t1;
119 select sql_cache * from t1;
120 end;//
121 create procedure f2 () begin
122 select sql_cache * from t1 where s1=1;
123 select sql_cache * from t1;
124 end;//
125 create procedure f3 () begin
126 select sql_cache * from t1;
127 select sql_cache * from t1 where s1=1;
128 end;//
129 create procedure f4 () begin
130 select sql_cache * from t1;
131 select sql_cache * from t1 where s1=1;
132 select sql_cache * from t1;
133 select sql_cache * from t1 where s1=1;
134 select sql_cache * from t1 where s1=1;
135 end;//
136 delimiter ;//
137 call f1();
138 --replace_result 1 3
139 show status like "Qcache_queries_in_cache";
140 show status like "Qcache_inserts";
141 show status like "Qcache_hits";
142 call f1();
143 show status like "Qcache_queries_in_cache";
144 show status like "Qcache_inserts";
145 show status like "Qcache_hits";
146 call f1();
147 select sql_cache * from t1;
148 show status like "Qcache_queries_in_cache";
149 show status like "Qcache_inserts";
150 show status like "Qcache_hits";
151 insert into t1 values (1);
152 select sql_cache * from t1;
153 show status like "Qcache_queries_in_cache";
154 show status like "Qcache_inserts";
155 show status like "Qcache_hits";
156 call f1();
157 call f1();
158 select sql_cache * from t1;
159 show status like "Qcache_queries_in_cache";
160 show status like "Qcache_inserts";
161 show status like "Qcache_hits";
162 flush query cache;
163 reset query cache;
164 flush status;
165 select sql_cache * from t1;
166 select sql_cache * from t1 where s1=1;
167 call f1();
168 call f2();
169 call f3();
170 call f4();
171 call f4();
172 call f3();
173 call f2();
174 select sql_cache * from t1 where s1=1;
175 insert into t1 values (2);
176 call f1();
177 select sql_cache * from t1 where s1=1;
178 select sql_cache * from t1;
179 call f1();
180 call f3();
181 call f3();
182 call f1();
184 drop procedure f1;
185 drop procedure f2;
186 drop procedure f3;
187 drop procedure f4;
188 drop table t1;
191 # Bug#14767 INSERT in SF + concurrent SELECT with query cache
193 connection default;
194 SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
195 SET GLOBAL log_bin_trust_function_creators = 1;
197 reset query cache;
198 --disable_warnings
199 drop function if exists f1;
200 --enable_warnings
201 create table t1 (id int);
202 delimiter |;
203 create function f1 ()
204   returns int
205 begin
206   declare i_var int;
207   set i_var = sleep(3);
208   insert into t1 values(3);
209   set i_var = sleep(3);
210   return 0;
211 end;|
212 delimiter ;|
214 connect (con1,localhost,root,,);
215 connect (con2,localhost,root,,);
217 connection con1;
218 send select f1();
219 connection con2;
220 select sleep(4);
221 select * from t1;
222 connection con1;
223 reap;
224 connection con2;
225 # This gives wrong result i.e. 't' table seems to be empty
226 select * from t1;
227 reset query cache;
228 select * from t1;
229 drop table t1;
230 drop function f1;
231 disconnect con1;
232 disconnect con2;
233 connection default;
235 set GLOBAL query_cache_size=0;
237 # End of 5.0 tests
239 SET @@global.log_bin_trust_function_creators = @old_log_bin_trust_function_creators;
242 # Bug #30269 Query cache eats memory
244 --disable_warnings
245 DROP DATABASE IF EXISTS bug30269;
246 --enable_warnings
247 FLUSH STATUS;
248 CREATE DATABASE bug30269;
249 USE bug30269;
250 CREATE TABLE test1 (id int, name varchar(23));
251 CREATE VIEW view1 AS SELECT * FROM test1;
252 INSERT INTO test1 VALUES (5, 'testit');
253 GRANT SELECT (id) ON TABLE bug30269.test1 TO 'bug30269'@'localhost';
254 GRANT SELECT ON TABLE bug30269.view1 TO 'bug30269'@'localhost';
255 set global query_cache_size= 81920;
256 connect (bug30269, localhost, bug30269,,);
257 connection bug30269;
258 USE bug30269;
259 show status like 'Qcache_queries_in_cache';
260 --echo # Select statement not stored in query cache because of column privileges.
261 SELECT id FROM test1 WHERE id>2;
262 show status like 'Qcache_queries_in_cache';
263 SELECT id FROM view1 WHERE id>2;
264 show status like 'Qcache_queries_in_cache';
266 connection default;
267 USE test;
268 DROP DATABASE bug30269;
269 disconnect bug30269;
270 DROP USER 'bug30269'@'localhost';
272 set GLOBAL query_cache_type=default;
273 set GLOBAL query_cache_limit=default;
274 set GLOBAL query_cache_min_res_unit=default;
275 set GLOBAL query_cache_size=default;
277 # Wait till we reached the initial number of concurrent sessions
278 --source include/wait_until_count_sessions.inc