1set GLOBAL query_cache_size=1355776; 2flush query cache; 3flush query cache; 4reset query cache; 5flush status; 6drop table if exists t1, t2, t3, t11, t21; 7create table t1 (a int not null); 8insert into t1 values (1),(2),(3); 9create table t2 (a int not null); 10insert into t2 values (1),(2),(3); 11select * from t1; 12a 131 142 153 16select * from t2; 17a 181 192 203 21insert into t1 values (4); 22show status like "Qcache_free_blocks"; 23Variable_name Value 24Qcache_free_blocks 2 25flush query cache; 26show status like "Qcache_free_blocks"; 27Variable_name Value 28Qcache_free_blocks 1 29drop table t1, t2; 30create table t1 (a text not null); 31create table t11 (a text not null); 32create table t2 (a text not null); 33create table t21 (a text not null); 34create table t3 (a text not null); 35insert into t1 values("1111111111111111111111111111111111111111111111111111"); 36insert into t2 select * from t1; 37insert into t1 select * from t2; 38insert into t2 select * from t1; 39insert into t1 select * from t2; 40insert into t2 select * from t1; 41insert into t1 select * from t2; 42insert into t2 select * from t1; 43insert into t1 select * from t2; 44insert into t2 select * from t1; 45insert into t1 select * from t2; 46insert into t2 select * from t1; 47insert into t1 select * from t2; 48insert into t2 select * from t1; 49insert into t1 select * from t2; 50insert into t2 select * from t1; 51insert into t11 select * from t1; 52insert into t21 select * from t1; 53insert into t1 select * from t2; 54insert into t2 select * from t1; 55insert into t1 select * from t2; 56insert into t3 select * from t1; 57insert into t3 select * from t2; 58insert into t3 select * from t1; 59select * from t11; 60select * from t21; 61show status like "Qcache_total_blocks"; 62Variable_name Value 63Qcache_total_blocks 7 64show status like "Qcache_free_blocks"; 65Variable_name Value 66Qcache_free_blocks 1 67insert into t11 values(""); 68select * from t3; 69show status like "Qcache_total_blocks"; 70Variable_name Value 71Qcache_total_blocks 8 72show status like "Qcache_free_blocks"; 73Variable_name Value 74Qcache_free_blocks 1 75flush query cache; 76show status like "Qcache_total_blocks"; 77Variable_name Value 78Qcache_total_blocks 7 79show status like "Qcache_free_blocks"; 80Variable_name Value 81Qcache_free_blocks 1 82drop table t1, t2, t3, t11, t21; 83CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY AUTO_INCREMENT ) ENGINE = 84MyISAM; 85LOCK TABLE t1 READ LOCAL; 86INSERT INTO t1 VALUES (), (), (); 87SELECT * FROM t1; 88a 89SELECT * FROM t1; 90a 911 922 933 94SELECT * FROM t1; 95a 96UNLOCK TABLES; 97drop table t1; 98flush query cache; 99reset query cache; 100flush status; 101create table t1 (s1 int)// 102create procedure f1 () begin 103select sql_cache * from t1; 104select sql_cache * from t1; 105select sql_cache * from t1; 106end;// 107create procedure f2 () begin 108select sql_cache * from t1 where s1=1; 109select sql_cache * from t1; 110end;// 111create procedure f3 () begin 112select sql_cache * from t1; 113select sql_cache * from t1 where s1=1; 114end;// 115create procedure f4 () begin 116select sql_cache * from t1; 117select sql_cache * from t1 where s1=1; 118select sql_cache * from t1; 119select sql_cache * from t1 where s1=1; 120select sql_cache * from t1 where s1=1; 121end;// 122call f1(); 123s1 124s1 125s1 126show status like "Qcache_queries_in_cache"; 127Variable_name Value 128Qcache_queries_in_cache 3 129show status like "Qcache_inserts"; 130Variable_name Value 131Qcache_inserts 3 132show status like "Qcache_hits"; 133Variable_name Value 134Qcache_hits 0 135call f1(); 136s1 137s1 138s1 139show status like "Qcache_queries_in_cache"; 140Variable_name Value 141Qcache_queries_in_cache 3 142show status like "Qcache_inserts"; 143Variable_name Value 144Qcache_inserts 3 145show status like "Qcache_hits"; 146Variable_name Value 147Qcache_hits 3 148call f1(); 149s1 150s1 151s1 152select sql_cache * from t1; 153s1 154show status like "Qcache_queries_in_cache"; 155Variable_name Value 156Qcache_queries_in_cache 4 157show status like "Qcache_inserts"; 158Variable_name Value 159Qcache_inserts 4 160show status like "Qcache_hits"; 161Variable_name Value 162Qcache_hits 6 163insert into t1 values (1); 164select sql_cache * from t1; 165s1 1661 167show status like "Qcache_queries_in_cache"; 168Variable_name Value 169Qcache_queries_in_cache 1 170show status like "Qcache_inserts"; 171Variable_name Value 172Qcache_inserts 5 173show status like "Qcache_hits"; 174Variable_name Value 175Qcache_hits 6 176call f1(); 177s1 1781 179s1 1801 181s1 1821 183call f1(); 184s1 1851 186s1 1871 188s1 1891 190select sql_cache * from t1; 191s1 1921 193show status like "Qcache_queries_in_cache"; 194Variable_name Value 195Qcache_queries_in_cache 4 196show status like "Qcache_inserts"; 197Variable_name Value 198Qcache_inserts 8 199show status like "Qcache_hits"; 200Variable_name Value 201Qcache_hits 10 202flush query cache; 203reset query cache; 204flush status; 205select sql_cache * from t1; 206s1 2071 208select sql_cache * from t1 where s1=1; 209s1 2101 211call f1(); 212s1 2131 214s1 2151 216s1 2171 218call f2(); 219s1 2201 221s1 2221 223call f3(); 224s1 2251 226s1 2271 228call f4(); 229s1 2301 231s1 2321 233s1 2341 235s1 2361 237s1 2381 239call f4(); 240s1 2411 242s1 2431 244s1 2451 246s1 2471 248s1 2491 250call f3(); 251s1 2521 253s1 2541 255call f2(); 256s1 2571 258s1 2591 260select sql_cache * from t1 where s1=1; 261s1 2621 263insert into t1 values (2); 264call f1(); 265s1 2661 2672 268s1 2691 2702 271s1 2721 2732 274select sql_cache * from t1 where s1=1; 275s1 2761 277select sql_cache * from t1; 278s1 2791 2802 281call f1(); 282s1 2831 2842 285s1 2861 2872 288s1 2891 2902 291call f3(); 292s1 2931 2942 295s1 2961 297call f3(); 298s1 2991 3002 301s1 3021 303call f1(); 304s1 3051 3062 307s1 3081 3092 310s1 3111 3122 313drop procedure f1; 314drop procedure f2; 315drop procedure f3; 316drop procedure f4; 317drop table t1; 318SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators; 319SET GLOBAL log_bin_trust_function_creators = 1; 320reset query cache; 321drop function if exists f1; 322create table t1 (id int); 323create function f1 () 324returns int 325begin 326declare i_var int; 327set i_var = sleep(3); 328insert into t1 values(3); 329set i_var = sleep(3); 330return 0; 331end;| 332select f1(); 333select sleep(4); 334sleep(4) 3350 336select * from t1; 337id 3383 339f1() 3400 341select * from t1; 342id 3433 344reset query cache; 345select * from t1; 346id 3473 348drop table t1; 349drop function f1; 350set GLOBAL query_cache_size=0; 351SET @@global.log_bin_trust_function_creators = @old_log_bin_trust_function_creators; 352DROP DATABASE IF EXISTS bug30269; 353FLUSH STATUS; 354CREATE DATABASE bug30269; 355USE bug30269; 356CREATE TABLE test1 (id int, name varchar(23)); 357CREATE VIEW view1 AS SELECT * FROM test1; 358INSERT INTO test1 VALUES (5, 'testit'); 359GRANT SELECT (id) ON TABLE bug30269.test1 TO 'bug30269'@'localhost'; 360GRANT SELECT ON TABLE bug30269.view1 TO 'bug30269'@'localhost'; 361set global query_cache_size= 81920; 362USE bug30269; 363show status like 'Qcache_queries_in_cache'; 364Variable_name Value 365Qcache_queries_in_cache 0 366# Select statement not stored in query cache because of column privileges. 367SELECT id FROM test1 WHERE id>2; 368id 3695 370show status like 'Qcache_queries_in_cache'; 371Variable_name Value 372Qcache_queries_in_cache 0 373SELECT id FROM view1 WHERE id>2; 374id 3755 376show status like 'Qcache_queries_in_cache'; 377Variable_name Value 378Qcache_queries_in_cache 1 379USE test; 380DROP DATABASE bug30269; 381DROP USER 'bug30269'@'localhost'; 382set GLOBAL query_cache_limit=default; 383set GLOBAL query_cache_min_res_unit=default; 384set GLOBAL query_cache_size=default; 385