1# TODO: Only run this if we have privilege to do flush table 2 3# 4# Test of flush table 5# 6 7# Should work in embedded server after mysqltest is fixed 8-- source include/not_embedded.inc 9--disable_warnings 10drop table if exists t1,t2; 11--enable_warnings 12create table t1 (a int not null auto_increment primary key); 13insert into t1 values(0); 14 15# Test for with read lock + flush 16 17lock table t1 read; 18--error ER_TABLE_NOT_LOCKED_FOR_WRITE 19flush table t1; 20unlock tables; 21 22# Test for with write lock + flush 23 24lock table t1 write; 25flush table t1; 26check table t1; 27unlock tables; 28 29# Test for with a write lock and a waiting read lock + flush 30 31lock table t1 write; 32connect (locker,localhost,root,,test); 33connection locker; 34send lock table t1 read; 35connection default; 36sleep 2; 37flush table t1; 38select * from t1; 39unlock tables; 40connection locker; 41reap; 42unlock tables; 43connection default; 44 45# Test for with a write lock and a waiting write lock + flush 46 47lock table t1 write; 48connection locker; 49send lock table t1 write; 50connection default; 51sleep 2; 52flush table t1; 53select * from t1; 54unlock tables; 55connection locker; 56reap; 57unlock tables; 58select * from t1; 59connection default; 60drop table t1; 61disconnect locker; 62 63# 64# In the following test FLUSH TABLES produces a deadlock 65# (hang forever) if the fix for BUG #3565 is missing. 66# And it shows that handler tables are re-opened after flush (BUG #4286). 67# 68create table t1(table_id char(20) primary key); 69create table t2(table_id char(20) primary key); 70insert into t1 values ('test.t1'); 71insert into t1 values (''); 72insert into t2 values ('test.t2'); 73insert into t2 values (''); 74handler t1 open as a1; 75handler t1 open as a2; 76handler t2 open; 77handler a1 read first limit 9; 78handler a2 read first limit 9; 79handler t2 read first limit 9; 80flush tables; 81handler a1 read first limit 9; 82handler a2 read first limit 9; 83handler t2 read first limit 9; 84# 85--error 1066 86handler t1 open as a1; 87--error 1066 88handler t1 open as a2; 89--error 1066 90handler t2 open; 91handler a1 read first limit 9; 92handler a2 read first limit 9; 93handler t2 read first limit 9; 94flush table t1; 95handler a1 read first limit 9; 96handler a2 read first limit 9; 97handler t2 read first limit 9; 98flush table t2; 99handler t2 close; 100drop table t1; 101drop table t2; 102 103# 104# The fix for BUG #4286 cannot restore the position after a flush. 105# 106create table t1(table_id char(20) primary key); 107insert into t1 values ('Record-01'); 108insert into t1 values ('Record-02'); 109insert into t1 values ('Record-03'); 110insert into t1 values ('Record-04'); 111insert into t1 values ('Record-05'); 112handler t1 open; 113handler t1 read first limit 1; 114handler t1 read next limit 1; 115handler t1 read next limit 1; 116flush table t1; 117handler t1 read next limit 1; 118handler t1 read next limit 1; 119handler t1 close; 120drop table t1; 121 122# 123# Bug #11934 Two sequential FLUSH TABLES WITH READ LOCK hangs client 124# 125FLUSH TABLES WITH READ LOCK ; 126FLUSH TABLES WITH READ LOCK ; 127UNLOCK TABLES; 128 129# End of 4.1 tests 130