~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
# We are using .opt file since we need small binlog size
2
# TODO: Need to look at making a row based version once the new row based client is completed. [jbm]
3
-- source include/have_binlog_format_mixed_or_statement.inc
4
5
-- source include/have_log_bin.inc
6
7
# we need this for getting fixed timestamps inside of this test
8
set timestamp=1000000000;
9
10
--disable_warnings
11
drop table if exists t1,t2,t3,t4,t5,t03,t04;
12
--enable_warnings
13
14
create table t1 (word varchar(20));
15
create table t2 (id int auto_increment not null primary key);
16
17
# simple test for simple statement and various events
18
insert into t1 values ("abirvalg");
19
insert into t2 values ();
20
# Should be uncommented in 4.1
21
# set @a:=1
22
# insert into t2 values (@a);
23
24
# test for load data and load data distributed among the several 
25
# files (we need to fill up first binlog)
26
load data infile '../std_data_ln/words.dat' into table t1;
27
load data infile '../std_data_ln/words.dat' into table t1;
28
load data infile '../std_data_ln/words.dat' into table t1;
29
load data infile '../std_data_ln/words.dat' into table t1;
30
load data infile '../std_data_ln/words.dat' into table t1;
31
# simple query to show more in second binlog
32
insert into t1 values ("Alas");
33
flush logs;
34
35
# delimiters are for easier debugging in future
36
--disable_query_log
37
select "--- Local --" as "";
38
--enable_query_log
39
40
#
41
# We should use --short-form everywhere because in other case output will
42
# be time dependend. Better than nothing.
43
#
44
45
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
46
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
47
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLTEST_VARDIR/log/master-bin.000001
48
49
# this should not fail but shouldn't produce any working statements
50
--disable_query_log
51
select "--- Broken LOAD DATA --" as "";
52
--enable_query_log
53
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
54
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
55
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLTEST_VARDIR/log/master-bin.000002 2> /dev/null
56
57
# this should show almost nothing
58
--disable_query_log
59
select "--- --database --" as "";
60
--enable_query_log
61
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
62
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
63
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --database=nottest $MYSQLTEST_VARDIR/log/master-bin.000001 2> /dev/null
64
65
# this test for position option
66
--disable_query_log
67
select "--- --position --" as "";
68
--enable_query_log
69
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
70
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
71
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=240 $MYSQLTEST_VARDIR/log/master-bin.000002
72
73
# These are tests for remote binlog.
74
# They should return the same as previous test.
75
76
--disable_query_log
77
select "--- Remote --" as "";
78
--enable_query_log
79
80
# This is broken now
81
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
82
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
83
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
84
85
# This is broken too
86
--disable_query_log
87
select "--- Broken LOAD DATA --" as "";
88
--enable_query_log
89
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
90
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
91
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 2> /dev/null
92
93
# And this too ! (altough it is documented)
94
--disable_query_log
95
select "--- --database --" as "";
96
--enable_query_log
97
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
98
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
99
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --database=nottest master-bin.000001 2> /dev/null
100
101
# Strangely but this works
102
--disable_query_log
103
select "--- --position --" as "";
104
--enable_query_log
105
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
106
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
107
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --position=240 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
108
109
# Bug#7853 (mysqlbinlog does not accept input from stdin)
110
--disable_query_log
111
select "--- reading stdin --" as "";
112
--enable_query_log
113
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
114
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
115
--exec $MYSQL_BINLOG --short-form - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001
116
117
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
118
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
119
--exec $MYSQL_BINLOG --short-form --position=79 - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001
120
drop table t1,t2;
121
122
#
123
#BUG#14157: utf8 encoding in binlog without set character_set_client
124
#
125
flush logs;
126
--write_file $MYSQLTEST_VARDIR/tmp/bug14157.sql
127
create table if not exists t5 (a int);
128
set names latin1;
129
create temporary table `äöüÄÖÜ` (a int);
130
insert into `äöüÄÖÜ` values (1);
131
insert into t5 select * from `äöüÄÖÜ`
132
EOF
133
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug14157.sql
134
--remove_file $MYSQLTEST_VARDIR/tmp/bug14157.sql
135
136
# resulted binlog, parly consisting of multi-byte utf8 chars, 
137
# must be digestable for both client and server. In 4.1 the client 
138
# should use default-character-set same as the server.
139
flush logs;
140
--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000004 | $MYSQL
141
select * from t5  /* must be (1),(1) */;
142
drop table t5;
143
144
#
145
# Bug#22645 LC_TIME_NAMES: Statement not replicated
146
# Check that a dump created by mysqlbinlog reproduces
147
# lc_time_names dependent values correctly
148
#
149
flush logs;
150
create table t5 (c1 int, c2 varchar(128) character set latin1 not null);
151
insert into t5 values (1, date_format('2001-01-01','%W'));
152
set lc_time_names=de_DE;
153
insert into t5 values (2, date_format('2001-01-01','%W'));
154
set lc_time_names=en_US;
155
insert into t5 values (3, date_format('2001-01-01','%W'));
156
select * from t5 order by c1;
157
flush logs;
158
drop table t5;
159
--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000006 | $MYSQL
160
select * from t5 order by c1;
161
drop table t5;
162
163
#
164
# Bug#20396 Bin Log does not get DELIMETER cmd - Recover StoredProc fails 
165
#
166
--disable_warnings
167
drop procedure if exists p1;
168
--enable_warnings
169
flush logs;
170
delimiter //;
171
create procedure p1()
172
begin
173
select 1;
174
end;
175
//
176
delimiter ;//
177
flush logs;
178
call p1();
179
drop procedure p1;
180
--error 1305
181
call p1();
182
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
183
--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000008
184
--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000008 | $MYSQL
185
call p1();
186
drop procedure p1;
187
188
#
189
# Some coverage of not normally used parts
190
#
191
--disable_query_log
192
--exec $MYSQL_BINLOG --version 2>&1 > /dev/null
193
--exec $MYSQL_BINLOG --help 2>&1 > /dev/null
194
--enable_query_log
195
196
#
197
# Bug#15126 character_set_database is not replicated
198
# (LOAD DATA INFILE need it)
199
#
200
201
flush logs;
202
create table t1 (a varchar(64) character set utf8);
203
load data infile '../std_data_ln/loaddata6.dat' into table t1;
204
set character_set_database=koi8r;
205
load data infile '../std_data_ln/loaddata6.dat' into table t1;
206
set character_set_database=latin1;
207
load data infile '../std_data_ln/loaddata6.dat' into table t1;
208
load data infile '../std_data_ln/loaddata6.dat' into table t1;
209
set character_set_database=koi8r;
210
load data infile '../std_data_ln/loaddata6.dat' into table t1;
211
set character_set_database=latin1;
212
load data infile '../std_data_ln/loaddata6.dat' into table t1;
213
load data infile '../std_data_ln/loaddata6.dat' into table t1 character set koi8r;
214
select hex(a) from t1;
215
drop table t1;
216
flush logs;
217
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
218
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
219
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLTEST_VARDIR/log/master-bin.000010
220
221
#
222
# Bug#28293 missed '#' sign in the hex dump when the dump length
223
# is divisible by 16.
224
#
225
226
CREATE TABLE t1 (c1 CHAR(10));
227
# we need this for getting fixed timestamps inside of this test
228
flush logs;
229
INSERT INTO t1 VALUES ('0123456789');
230
flush logs;
231
DROP TABLE t1;
232
--exec $MYSQL_BINLOG --hexdump --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLTEST_VARDIR/log/master-bin.000012 | grep 'Query' | sed 's/[0-9]\{1,\}/REMOVED/g'
233
234
#
235
# Bug #29928: incorrect connection_id() restoring from mysqlbinlog out
236
#
237
flush logs;
238
create table t1(a int);
239
insert into t1 values(connection_id()); 
240
let $a= `select a from t1`;
241
flush logs;
242
--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000014 > $MYSQLTEST_VARDIR/tmp/bug29928.sql
243
drop table t1;
244
connect (con1, localhost, root, , test);                                            
245
connection con1;
246
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug29928.sql
247
--remove_file $MYSQLTEST_VARDIR/tmp/bug29928.sql
248
let $b= `select a from t1`;
249
disconnect con1;
250
connection default;
251
let $c= `select $a=$b`;
252
--echo $c
253
drop table t1;
254
255
echo shell> mysqlbinlog std_data/corrupt-relay-bin.000624 > var/tmp/bug31793.sql;
256
error 1;
257
exec $MYSQL_BINLOG $MYSQL_TEST_DIR/std_data/corrupt-relay-bin.000624 > $MYSQLTEST_VARDIR/tmp/bug31793.sql;
258
259
--echo End of 5.0 tests
260
261
#
262
# Test --disable-force-if-open and --force-if-open
263
#
264
flush logs;
265
--error 1
266
--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000016 >/dev/null 2>/dev/null
267
--exec $MYSQL_BINLOG --force-if-open $MYSQLTEST_VARDIR/log/master-bin.000016 >/dev/null 2>/dev/null
268
269
--echo BUG#31611: Security risk with BINLOG statement
270
271
SET BINLOG_FORMAT=ROW;
272
CREATE DATABASE mysqltest1;
273
CREATE USER untrusted@localhost;
274
GRANT SELECT ON mysqltest1.* TO untrusted@localhost;
275
276
SHOW GRANTS FOR untrusted@localhost;
277
USE mysqltest1;
278
CREATE TABLE t1 (a INT, b CHAR(64));
279
flush logs;
280
INSERT INTO t1 VALUES (1,USER());
281
flush logs;
282
echo mysqlbinlog var/log/master-bin.000017 > var/tmp/bug31611.sql;
283
exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000017 > $MYSQLTEST_VARDIR/tmp/bug31611.sql;
284
connect (unsecure,localhost,untrusted,,mysqltest1);
285
echo mysql mysqltest1 -uuntrusted < var/tmp/bug31611.sql;
286
error 1;
287
exec $MYSQL mysqltest1 -uuntrusted < $MYSQLTEST_VARDIR/tmp/bug31611.sql;
288
connection unsecure;
289
error ER_TABLEACCESS_DENIED_ERROR;
290
INSERT INTO t1 VALUES (1,USER());
291
292
SELECT * FROM t1;
293
connection default;
294
DROP DATABASE mysqltest1;
295
DROP USER untrusted@localhost;
296
297
--echo BUG#32580: mysqlbinlog cannot read binlog event with user variables
298
299
# Testing that various kinds of events can be read and restored properly.
300
301
connection default;
302
USE test;
303
SET BINLOG_FORMAT = STATEMENT;
304
FLUSH LOGS;
305
CREATE TABLE t1 (a_real FLOAT, an_int INT, a_decimal DECIMAL(5,2), a_string CHAR(32));
306
SET @a_real = rand(20) * 1000;
307
SET @an_int = 1000;
308
SET @a_decimal = CAST(rand(19) * 999 AS DECIMAL(5,2));
309
SET @a_string = 'Just a test';
310
INSERT INTO t1 VALUES (@a_real, @an_int, @a_decimal, @a_string);
311
FLUSH LOGS;
312
query_vertical SELECT * FROM t1;
313
DROP TABLE t1;
314
315
echo >> mysqlbinlog var/log/master-bin.000019 > var/tmp/bug32580.sql;
316
exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000019 > $MYSQLTEST_VARDIR/tmp/bug32580.sql;
317
echo >> mysql test < var/tmp/bug32580.sql;
318
exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug32580.sql;
319
remove_file $MYSQLTEST_VARDIR/tmp/bug32580.sql;
320
321
query_vertical SELECT * FROM t1;
322
DROP TABLE t1;
323
324
--echo End of 5.1 tests