1-- source include/have_binlog_format_row.inc
2#
3# Reset master to cleanup binlog
4#
5reset master;
6
7#
8#  Write different events to binlog
9#
10create table t1 (a int);
11insert into t1 values (1);
12insert into t1 values (2);
13insert into t1 values (3);
14update t1 set a=a+2 where a=2;
15update t1 set a=a+2 where a=3;
16
17create table t2 (word varchar(20));
18load data infile '../../std_data/words.dat' into table t2;
19
20#
21#  Save binlog
22#
23let $MYSQLD_DATADIR=`select @@datadir`;
24let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
25flush logs;
26--exec $MYSQL_BINLOG --hexdump $MYSQLD_DATADIR/$binlog_file > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql
27
28#
29#  Clear database and restore from binlog
30#
31drop table t1;
32drop table t2;
33RESET MASTER;
34--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql
35
36#
37#  Verify that all binlog events have been executed
38#
39select * from t1;
40select * from t2;
41
42#
43#  Verify that events larger than the default IO_CACHE buffer
44#  are handled correctly (BUG#25628).
45#
46flush logs;
47drop table t2;
48create table t2 (word varchar(20));
49load data infile '../../std_data/words.dat' into table t2;
50insert into t2 select * from t2;
51insert into t2 select * from t2;
52insert into t2 select * from t2;
53insert into t2 select * from t2;
54insert into t2 select * from t2;
55insert into t2 select * from t2;
56insert into t2 select * from t2;
57insert into t2 select * from t2;
58insert into t2 select * from t2;
59select count(*) from t2;
60
61let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
62flush logs;
63--exec $MYSQL_BINLOG --hexdump $MYSQLD_DATADIR/$binlog_file > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql
64RESET MASTER;
65--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql
66
67#
68#  Verify that all binlog events have been executed
69#
70select count(*) from t2;
71
72#
73#  Test cleanup
74#
75--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_base64.sql
76drop table t1;
77drop table t2;
78
79#
80# BUG#12354268
81#
82# This test verifies that using --start-position with DECODE-ROWS
83# does not make mysqlbinlog to output an error stating that it
84# does not contain any FD event.
85#
86
87RESET MASTER;
88USE test;
89SET @old_binlog_format= @@binlog_format;
90SET SESSION binlog_format=ROW;
91CREATE TABLE t1(c1 INT);
92--let $master_binlog= query_get_value(SHOW MASTER STATUS, File, 1)
93--let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1)
94--let $MYSQLD_DATADIR= `SELECT @@datadir`
95
96INSERT INTO t1 VALUES (1);
97
98FLUSH LOGS;
99
100--disable_result_log
101--exec $MYSQL_BINLOG --base64-output=DECODE-ROWS --start-position=$master_pos -v $MYSQLD_DATADIR/$master_binlog
102--enable_result_log
103
104DROP TABLE t1;
105SET SESSION binlog_format= @old_binlog_format;
106RESET MASTER;
107