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
5
-- source include/have_log_bin.inc
7
# Deletes all the binary logs
10
# we need this for getting fixed timestamps inside of this test
11
set timestamp=1000000000;
14
drop table if exists t1,t2,t3,t4,t5,t03,t04;
17
create table t1 (word varchar(20));
18
create table t2 (id int auto_increment not null primary key);
20
# simple test for simple statement and various events
21
insert into t1 values ("abirvalg");
22
insert into t2 values ();
23
# Should be uncommented in 4.1
25
# insert into t2 values (@a);
27
# test for load data and load data distributed among the several
28
# files (we need to fill up first binlog)
29
load data infile '../../std_data/words.dat' into table t1;
30
load data infile '../../std_data/words.dat' into table t1;
31
load data infile '../../std_data/words.dat' into table t1;
32
load data infile '../../std_data/words.dat' into table t1;
33
load data infile '../../std_data/words.dat' into table t1;
34
# simple query to show more in second binlog
35
insert into t1 values ("Alas");
38
# delimiters are for easier debugging in future
40
select "--- Local --" as "";
44
# We should use --short-form everywhere because in other case output will
45
# be time dependend. Better than nothing.
47
let $MYSQLD_DATADIR= `select @@datadir`;
48
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
49
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
50
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000001
52
# this should not fail but shouldn't produce any working statements
54
select "--- Broken LOAD DATA --" as "";
56
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
57
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
58
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000002 2> /dev/null
60
# this should show almost nothing
62
select "--- --database --" as "";
64
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
65
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
66
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --database=nottest $MYSQLD_DATADIR/master-bin.000001 2> /dev/null
68
# this test for position option
70
select "--- --position --" as "";
72
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
73
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
74
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=332 $MYSQLD_DATADIR/master-bin.000002
77
# These are tests for remote binlog.
78
# They should return the same as previous test.
81
select "--- Remote --" as "";
85
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
86
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
87
--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
91
select "--- Broken LOAD DATA --" as "";
93
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
94
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
95
--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
97
# And this too ! (altough it is documented)
99
select "--- --database --" as "";
101
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
102
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
103
--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
105
# Strangely but this works
107
select "--- --position --" as "";
109
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
110
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
111
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --position=332 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
113
# Bug#7853 mysqlbinlog does not accept input from stdin
115
select "--- reading stdin --" as "";
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 - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001
121
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
122
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
123
--exec $MYSQL_BINLOG --short-form --position=79 - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001
127
# Bug#14157 utf8 encoding in binlog without set character_set_client
130
--write_file $MYSQLTEST_VARDIR/tmp/bug14157.sql
131
create table if not exists t5 (a int);
133
create temporary table `ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½` (a int);
134
insert into `ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½` values (1);
135
insert into t5 select * from `ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½`
137
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug14157.sql
138
--remove_file $MYSQLTEST_VARDIR/tmp/bug14157.sql
140
# resulted binlog, parly consisting of multi-byte utf8 chars,
141
# must be digestable for both client and server. In 4.1 the client
142
# should use default-character-set same as the server.
144
--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000004 | $MYSQL
145
select * from t5 /* must be (1),(1) */;
149
# Bug#22645 LC_TIME_NAMES: Statement not replicated
150
# Check that a dump created by mysqlbinlog reproduces
151
# lc_time_names dependent values correctly
154
create table t5 (c1 int, c2 varchar(128) character set latin1 not null);
155
insert into t5 values (1, date_format('2001-01-01','%W'));
156
set lc_time_names=de_DE;
157
insert into t5 values (2, date_format('2001-01-01','%W'));
158
set lc_time_names=en_US;
159
insert into t5 values (3, date_format('2001-01-01','%W'));
160
select * from t5 order by c1;
163
--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000006 | $MYSQL
164
select * from t5 order by c1;
168
# Bug#20396 Bin Log does not get DELIMETER cmd - Recover StoredProc fails
171
drop procedure if exists p1;
175
create procedure p1()
184
--error ER_SP_DOES_NOT_EXIST
186
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
187
--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000008
188
--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000008 | $MYSQL
193
# Some coverage of not normally used parts
196
--exec $MYSQL_BINLOG --version 2>&1 > /dev/null
197
--exec $MYSQL_BINLOG --help 2>&1 > /dev/null
201
# Bug#15126 character_set_database is not replicated
202
# (LOAD DATA INFILE need it)
206
create table t1 (a varchar(64) character set utf8);
207
load data infile '../../std_data/loaddata6.dat' into table t1;
208
set character_set_database=koi8r;
209
load data infile '../../std_data/loaddata6.dat' into table t1;
210
set character_set_database=latin1;
211
load data infile '../../std_data/loaddata6.dat' into table t1;
212
load data infile '../../std_data/loaddata6.dat' into table t1;
213
set character_set_database=koi8r;
214
load data infile '../../std_data/loaddata6.dat' into table t1;
215
set character_set_database=latin1;
216
load data infile '../../std_data/loaddata6.dat' into table t1;
217
load data infile '../../std_data/loaddata6.dat' into table t1 character set koi8r;
218
select hex(a) from t1;
221
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
222
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/
223
--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000010
226
# Bug#28293 missed '#' sign in the hex dump when the dump length
227
# is divisible by 16.
230
CREATE TABLE t1 (c1 CHAR(10));
231
# we need this for getting fixed timestamps inside of this test
233
INSERT INTO t1 VALUES ('0123456789');
237
# We create a table, patch, and load the output into it
238
# By using LINES STARTING BY '#' + SELECT WHERE a LIKE 'Query'
239
# We can easily see if a 'Query' line is missing the '#' character
240
# as described in the original bug
243
CREATE TABLE patch (a BLOB);
244
--exec $MYSQL_BINLOG --hexdump --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000012 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_tmp.dat
245
eval LOAD DATA LOCAL INFILE '$MYSQLTEST_VARDIR/tmp/mysqlbinlog_tmp.dat'
246
INTO TABLE patch FIELDS TERMINATED BY '' LINES STARTING BY '#';
247
--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_tmp.dat
250
--echo We expect this value to be 1
251
--echo The bug being tested was that 'Query' lines were not preceded by '#'
252
--echo If the line is in the table, it had to have been preceded by a '#'
254
SELECT COUNT(*) AS `BUG#28293_expect_1` FROM patch WHERE a LIKE '%Query%';
258
# Bug#29928 incorrect connection_id() restoring from mysqlbinlog out
261
CREATE TABLE t1(a INT);
262
INSERT INTO t1 VALUES(connection_id());
263
let $a= `SELECT a FROM t1`;
265
let $outfile= $MYSQLTEST_VARDIR/tmp/bug29928.sql;
266
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000014 > $outfile
268
connect (con1, localhost, root, , test);
270
--exec $MYSQL test < $outfile
271
--remove_file $outfile
272
let $b= `SELECT a FROM t1`;
275
let $c= `SELECT $a=$b`;
279
echo shell> mysqlbinlog std_data/corrupt-relay-bin.000624 > var/tmp/bug31793.sql;
281
exec $MYSQL_BINLOG $MYSQL_TEST_DIR/std_data/corrupt-relay-bin.000624 > $MYSQLTEST_VARDIR/tmp/bug31793.sql;
282
--remove_file $MYSQLTEST_VARDIR/tmp/bug31793.sql
286
# Test --disable-force-if-open and --force-if-open
290
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000016 >/dev/null 2>/dev/null
291
--exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/master-bin.000016 >/dev/null 2>/dev/null
293
--echo Bug#31611 Security risk with BINLOG statement
295
SET BINLOG_FORMAT=ROW;
296
CREATE DATABASE mysqltest1;
297
CREATE USER untrusted@localhost;
298
GRANT SELECT ON mysqltest1.* TO untrusted@localhost;
300
SHOW GRANTS FOR untrusted@localhost;
302
CREATE TABLE t1 (a INT, b CHAR(64));
304
INSERT INTO t1 VALUES (1,USER());
306
echo mysqlbinlog var/log/master-bin.000017 > var/tmp/bug31611.sql;
307
exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000017 > $MYSQLTEST_VARDIR/tmp/bug31611.sql;
308
connect (unsecure,localhost,untrusted,,mysqltest1);
309
echo mysql mysqltest1 -uuntrusted < var/tmp/bug31611.sql;
311
exec $MYSQL mysqltest1 -uuntrusted < $MYSQLTEST_VARDIR/tmp/bug31611.sql;
312
--remove_file $MYSQLTEST_VARDIR/tmp/bug31611.sql
314
error ER_TABLEACCESS_DENIED_ERROR;
315
INSERT INTO t1 VALUES (1,USER());
319
DROP DATABASE mysqltest1;
320
DROP USER untrusted@localhost;
322
--echo Bug#32580 mysqlbinlog cannot read binlog event with user variables
324
# Testing that various kinds of events can be read and restored properly.
328
SET BINLOG_FORMAT = STATEMENT;
330
CREATE TABLE t1 (a_real FLOAT, an_int INT, a_decimal DECIMAL(5,2), a_string CHAR(32));
331
SET @a_real = rand(20) * 1000;
333
SET @a_decimal = CAST(rand(19) * 999 AS DECIMAL(5,2));
334
SET @a_string = 'Just a test';
335
INSERT INTO t1 VALUES (@a_real, @an_int, @a_decimal, @a_string);
337
query_vertical SELECT * FROM t1;
340
echo >> mysqlbinlog var/log/master-bin.000019 > var/tmp/bug32580.sql;
341
exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000019 > $MYSQLTEST_VARDIR/tmp/bug32580.sql;
342
echo >> mysql test < var/tmp/bug32580.sql;
343
exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug32580.sql;
344
remove_file $MYSQLTEST_VARDIR/tmp/bug32580.sql;
346
query_vertical SELECT * FROM t1;
350
# Bug#37313 BINLOG Contains Incorrect server id
353
let $binlog_file= $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug37313.binlog;
354
let $save_server_id= `SELECT @@global.server_id`;
355
let $s_id_max= `SELECT (1 << 32) - 1`;
356
eval SET @@global.server_id= $s_id_max;
360
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $binlog_file
361
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
363
(@a:=LOAD_FILE("$binlog_file"))
365
let $s_id_unsigned= `SELECT @a LIKE "%server id $s_id_max%" /* must return 1 */`;
366
echo *** Unsigned server_id $s_id_max is found: $s_id_unsigned ***;
368
eval SET @@global.server_id= $save_server_id;
369
--remove_file $binlog_file
372
# Bug #41943: mysqlbinlog.exe crashes if --hexdump option is used
378
# We do not need the results, just make sure that mysqlbinlog does not crash
379
--exec $MYSQL_BINLOG --hexdump --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 >/dev/null
383
# This test verifies if the 'BEGIN', 'COMMIT' and 'ROLLBACK' are output
384
# in regardless of database filtering
390
# The following three test cases were wrtten into binlog_transaction.000001
391
# Test case1: Test if the 'BEGIN' and 'COMMIT' are output for the 'test' database
392
# in transaction1 base on innodb engine tables
394
# create table t1(a int) engine= innodb;
396
# create table t2(a int) engine= innodb;
400
# insert into t1 (a) values (1);
402
# insert into t2 (a) values (1);
406
# Test case2: Test if the 'BEGIN' and 'ROLLBACK' are output for the 'test' database
407
# in transaction2 base on innodb and myisam engine tables
409
# create table t3(a int) engine= innodb;
411
# create table t4(a int) engine= myisam;
415
# insert into t3 (a) values (2);
417
# insert into t4 (a) values (2);
421
# Test case3: Test if the 'BEGIN' and 'COMMIT' are output for the 'test' database
422
# in transaction3 base on NDB engine tables
424
# create table t5(a int) engine= NDB;
426
# create table t6(a int) engine= NDB;
430
# insert into t5 (a) values (3);
432
# insert into t6 (a) values (3);
437
--echo # Test if the 'BEGIN', 'ROLLBACK' and 'COMMIT' are output if the database specified is exist
438
--exec $MYSQL_BINLOG --database=test --short-form $MYSQLTEST_VARDIR/std_data/binlog_transaction.000001
440
--echo # Test if the 'BEGIN', 'ROLLBACK' and 'COMMIT' are output if the database specified is not exist
441
--exec $MYSQL_BINLOG --database=not_exist --short-form $MYSQLTEST_VARDIR/std_data/binlog_transaction.000001
443
--echo End of 5.0 tests
445
--echo End of 5.1 tests