mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / t / rename.test
blob5aa1a51a90f4d3be8556581dbba8248f20df2780
2 # Test of rename table
5 --source include/count_sessions.inc
7 --disable_warnings
8 drop table if exists t0,t1,t2,t3,t4;
9 # Clear up from other tests (to ensure that SHOW TABLES below is right)
10 drop table if exists t0,t5,t6,t7,t8,t9,t1_1,t1_2,t9_1,t9_2;
11 --enable_warnings
13 create table t0 SELECT 1,"table 1";
14 create table t2 SELECT 2,"table 2";
15 create table t3 SELECT 3,"table 3";
16 rename table t0 to t1;
17 rename table t3 to t4, t2 to t3, t1 to t2, t4 to t1;
18 select * from t1;
19 rename table t3 to t4, t2 to t3, t1 to t2, t4 to t1;
20 rename table t3 to t4, t2 to t3, t1 to t2, t4 to t1;
21 select * from t1;
23 # The following should give errors
24 --error ER_TABLE_EXISTS_ERROR,ER_TABLE_EXISTS_ERROR
25 rename table t1 to t2;
26 --error ER_TABLE_EXISTS_ERROR,ER_TABLE_EXISTS_ERROR
27 rename table t1 to t1;
28 --error ER_TABLE_EXISTS_ERROR,ER_TABLE_EXISTS_ERROR
29 rename table t3 to t4, t2 to t3, t1 to t2, t4 to t2;
30 show tables like "t_";
31 --error ER_TABLE_EXISTS_ERROR,ER_TABLE_EXISTS_ERROR
32 rename table t3 to t1, t2 to t3, t1 to t2, t4 to t1;
33 --error ER_FILE_NOT_FOUND,ER_FILE_NOT_FOUND
34 rename table t3 to t4, t5 to t3, t1 to t2, t4 to t1;
36 select * from t1;
37 select * from t2;
38 select * from t3;
40 # This should give a warning for t4
41 drop table if exists t1,t2,t3,t4;
44 # Bug #2397 RENAME TABLES is not blocked by
45 # FLUSH TABLES WITH READ LOCK
48 connect (con1,localhost,root,,);
49 connect (con2,localhost,root,,);
51 connection con1;
52 CREATE TABLE t1 (a int);
53 CREATE TABLE t3 (a int);
54 connection con2;
55 FLUSH TABLES WITH READ LOCK;
56 connection con1;
57 send RENAME TABLE t1 TO t2, t3 to t4;
58 connection con2;
59 show tables;
60 UNLOCK TABLES;
61 connection con1;
62 reap;
63 connection con2;
65 # Wait for the the tables to be renamed
66 # i.e the query below succeds
67 let $query= select * from t2, t4;
68 source include/wait_for_query_to_succeed.inc;
70 show tables;
72 drop table t2, t4;
74 disconnect con2;
75 disconnect con1;
76 connection default;
79 --echo End of 4.1 tests
83 # Bug#14959: ALTER TABLE isn't able to rename a view
85 create table t1(f1 int);
86 create view v1 as select * from t1;
87 alter table v1 rename to v2;
88 --error ER_NO_SUCH_TABLE
89 alter table v1 rename to v2;
90 rename table v2 to v1;
91 --error ER_TABLE_EXISTS_ERROR
92 rename table v2 to v1;
93 drop view v1;
94 drop table t1;
96 --echo End of 5.0 tests
98 --source include/wait_until_count_sessions.inc