mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / suite / engines / funcs / t / rpl_temporary.test
blob1539abeaceb6ca5321edcfce98cb7722bdd252a8
2 -- source include/master-slave.inc
4 # Clean up old slave's binlogs.
5 # The slave is started with --log-slave-updates
6 # and this test does SHOW BINLOG EVENTS on the slave's
7 # binlog. But previous tests can influence the current test's
8 # binlog (e.g. a temporary table in the previous test has not
9 # been explicitly deleted, or it has but the slave hasn't had
10 # enough time to catch it before STOP SLAVE, 
11 # and at the beginning of the current
12 # test the slave immediately writes DROP TEMPORARY TABLE this_old_table).
13 # We wait for the slave to have written all he wants to the binlog
14 # (otherwise RESET MASTER may come too early).
15 save_master_pos;
16 connection slave;
17 sync_with_master;
18 reset master;
19 connection master;
21 connect (con1,localhost,root,,);
23 #added on 2007/5/18
24 connection con1;
25 CREATE USER ''@localhost;
27 connect (con2,localhost,root,,);
28 # We want to connect as an unprivileged user. But if we use user="" then this
29 # will pick the Unix login, which will cause problems if you're running the test
30 # as root.
31 connect (con3,localhost,zedjzlcsjhd,,);
33 # We are going to use SET PSEUDO_THREAD_ID in this test;
34 # check that it requires the SUPER privilege.
36 connection con3;
37 SET @save_select_limit=@@session.sql_select_limit;
38 --error 1227
39 SET @@session.sql_select_limit=10, @@session.pseudo_thread_id=100;
40 SELECT @@session.sql_select_limit = @save_select_limit; #shouldn't have changed
41 # While we are here we also test that SQL_LOG_BIN can't be set
42 --error 1227
43 SET @@session.sql_select_limit=10, @@session.sql_log_bin=0;
44 SELECT @@session.sql_select_limit = @save_select_limit; #shouldn't have changed
45 # Now as root, to be sure it works
46 connection con2;
47 SET @@session.pseudo_thread_id=100;
48 SET @@session.pseudo_thread_id=connection_id();
49 SET @@session.sql_log_bin=0;
50 SET @@session.sql_log_bin=1;
52 connection con3;
53 let $VERSION=`select version()`;
55 --disable_warnings
56 drop table if exists t1,t2;
57 --enable_warnings
59 create table t1(f int);
60 create table t2(f int);
61 insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
63 connection con1;
64 create temporary table t3(f int);
65 insert into t3 select * from t1 where f<6;
66 sleep 1;
68 connection con2;
69 create temporary table t3(f int);
70 sleep 1;
72 connection con1;
73 insert into t2 select count(*) from t3;
74 sleep 1;
76 connection con2;
77 insert into t3 select * from t1 where f>=4;
78 sleep 1;
80 connection con1;
81 drop temporary table t3;
82 sleep 1;
84 connection con2;
85 insert into t2 select count(*) from t3;
86 drop temporary table t3;
88 select * from t2 ORDER BY f;
90 # Commented out 8/30/2005 to make compatable with both sbr and rbr
91 #--replace_result $VERSION VERSION
92 #--replace_column 2 # 5 #
93 #show binlog events;
95 drop table t1, t2;
97 use test;
98 SET TIMESTAMP=1040323920;
99 create table t1(f int);
100 SET TIMESTAMP=1040323931;
101 create table t2(f int);
102 SET TIMESTAMP=1040323938;
103 insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
105 SET TIMESTAMP=1040323945;
106 SET @@session.pseudo_thread_id=1;
107 create temporary table t3(f int);
108 SET TIMESTAMP=1040323952;
109 SET @@session.pseudo_thread_id=1;
110 insert into t3 select * from t1 where f<6;
111 SET TIMESTAMP=1040324145;
112 SET @@session.pseudo_thread_id=2;
113 create temporary table t3(f int);
114 SET TIMESTAMP=1040324186;
115 SET @@session.pseudo_thread_id=1;
116 insert into t2 select count(*) from t3;
117 SET TIMESTAMP=1040324200;
118 SET @@session.pseudo_thread_id=2;
119 insert into t3 select * from t1 where f>=4;
120 SET TIMESTAMP=1040324211;
121 SET @@session.pseudo_thread_id=1;
122 drop temporary table t3;
123 SET TIMESTAMP=1040324219;
124 SET @@session.pseudo_thread_id=2;
125 insert into t2 select count(*) from t3;
126 SET TIMESTAMP=1040324224;
127 SET @@session.pseudo_thread_id=2;
128 drop temporary table t3;
130 select * from t2 ORDER BY f;
131 drop table t1,t2;
133 # Create last a temporary table that is not dropped at end to ensure that we
134 # don't get any memory leaks for this
136 create temporary table t3 (f int);
137 #sync_with_master;
139 # The server will now close done
142 # Bug#17284 erroneous temp table cleanup on slave
145 connection master;
146 create temporary table t4 (f int);
147 create table t5 (f int);
148 #sync_with_master;
149 # find dumper's $id
150 select id from information_schema.processlist where command='Binlog Dump' into @id;
151 kill @id; # to stimulate reconnection by slave w/o timeout
152 insert into t5 select * from t4;
153 save_master_pos;
155 connection slave;
156 sync_with_master;
157 select * from t5 /* must be 1 after reconnection */;
159 connection master;
160 drop temporary table t4;
161 drop table t5;
164 # BUG#17263 incorrect generation DROP temp tables
165 # Temporary tables of connection are dropped in batches
166 # where a batch correspond to pseudo_thread_id
167 # value was set up at the moment of temp table creation
169 connection con1;
170 set @@session.pseudo_thread_id=100;
171 create temporary table t101 (id int);
172 create temporary table t102 (id int);
173 set @@session.pseudo_thread_id=200;
174 create temporary table t201 (id int);
175 create temporary table `t``201` (id int);
176 # emulate internal temp table not to come to binlog
177 create temporary table `#sql_not_user_table202` (id int);
178 set @@session.pseudo_thread_id=300;
179 create temporary table t301 (id int);
180 create temporary table t302 (id int);
181 create temporary table `#sql_not_user_table303` (id int);
184 #Added on 2007/5/18
185 DROP USER ''@localhost;
187 disconnect con1;
189 #now do something to show that slave is ok after DROP temp tables
190 connection master;
191 create table t1(f int);
192 insert into t1 values (1);
194 sync_slave_with_master;
195 #connection slave;
196 select * from t1 /* must be 1 */;
198 connection master; 
199 drop table t1;
202 #14157: utf8 encoding in binlog without set character_set_client
204 exec $MYSQL --character-sets-dir=../sql/share/charsets/ --default-character-set=latin1 test -e "create table t1 (a int); set names latin1; create temporary table äöüÄÖÜ (a int); insert into äöüÄÖÜ values (1); insert into t1 select * from äöüÄÖÜ";
206 sync_slave_with_master;
207 #connection slave;
208 select * from t1;
210 connection master; 
211 drop table t1;
213 # End of 5.1 tests