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
# we need this for getting fixed timestamps inside of this test
8
set timestamp=1000000000;
11
drop table if exists t1,t2,t3,t4,t5,t03,t04;
14
create table t1 (word varchar(20));
15
create table t2 (id int auto_increment not null primary key);
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
22
# insert into t2 values (@a);
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");
35
# delimiters are for easier debugging in future
37
select "--- Local --" as "";
41
# We should use --short-form everywhere because in other case output will
42
# be time dependend. Better than nothing.
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
49
# this should not fail but shouldn't produce any working statements
51
select "--- Broken LOAD DATA --" as "";
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
57
# this should show almost nothing
59
select "--- --database --" as "";
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
65
# this test for position option
67
select "--- --position --" as "";
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
73
# These are tests for remote binlog.
74
# They should return the same as previous test.
77
select "--- Remote --" as "";
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
87
select "--- Broken LOAD DATA --" as "";
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
93
# And this too ! (altough it is documented)
95
select "--- --database --" as "";
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
101
# Strangely but this works
103
select "--- --position --" as "";
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
109
# Bug#7853 (mysqlbinlog does not accept input from stdin)
111
select "--- reading stdin --" as "";
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
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
123
#BUG#14157: utf8 encoding in binlog without set character_set_client
126
--write_file $MYSQLTEST_VARDIR/tmp/bug14157.sql
127
create table if not exists t5 (a int);
129
create temporary table `������` (a int);
130
insert into `������` values (1);
131
insert into t5 select * from `������`
133
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug14157.sql
134
--remove_file $MYSQLTEST_VARDIR/tmp/bug14157.sql
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.
140
--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000004 | $MYSQL
141
select * from t5 /* must be (1),(1) */;
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
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;
159
--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000006 | $MYSQL
160
select * from t5 order by c1;
164
# Bug#20396 Bin Log does not get DELIMETER cmd - Recover StoredProc fails
167
drop procedure if exists p1;
171
create procedure 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
189
# Some coverage of not normally used parts
192
--exec $MYSQL_BINLOG --version 2>&1 > /dev/null
193
--exec $MYSQL_BINLOG --help 2>&1 > /dev/null
197
# Bug#15126 character_set_database is not replicated
198
# (LOAD DATA INFILE need it)
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;
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
222
# Bug#28293 missed '#' sign in the hex dump when the dump length
223
# is divisible by 16.
226
CREATE TABLE t1 (c1 CHAR(10));
227
# we need this for getting fixed timestamps inside of this test
229
INSERT INTO t1 VALUES ('0123456789');
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'
235
# Bug #29928: incorrect connection_id() restoring from mysqlbinlog out
238
create table t1(a int);
239
insert into t1 values(connection_id());
240
let $a= `select a from t1`;
242
--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000014 > $MYSQLTEST_VARDIR/tmp/bug29928.sql
244
connect (con1, localhost, root, , test);
246
--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug29928.sql
247
--remove_file $MYSQLTEST_VARDIR/tmp/bug29928.sql
248
let $b= `select a from t1`;
251
let $c= `select $a=$b`;
255
echo shell> mysqlbinlog std_data/corrupt-relay-bin.000624 > var/tmp/bug31793.sql;
257
exec $MYSQL_BINLOG $MYSQL_TEST_DIR/std_data/corrupt-relay-bin.000624 > $MYSQLTEST_VARDIR/tmp/bug31793.sql;
259
--echo End of 5.0 tests
262
# Test --disable-force-if-open and --force-if-open
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
269
--echo BUG#31611: Security risk with BINLOG statement
271
SET BINLOG_FORMAT=ROW;
272
CREATE DATABASE mysqltest1;
273
CREATE USER untrusted@localhost;
274
GRANT SELECT ON mysqltest1.* TO untrusted@localhost;
276
SHOW GRANTS FOR untrusted@localhost;
278
CREATE TABLE t1 (a INT, b CHAR(64));
280
INSERT INTO t1 VALUES (1,USER());
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;
287
exec $MYSQL mysqltest1 -uuntrusted < $MYSQLTEST_VARDIR/tmp/bug31611.sql;
289
error ER_TABLEACCESS_DENIED_ERROR;
290
INSERT INTO t1 VALUES (1,USER());
294
DROP DATABASE mysqltest1;
295
DROP USER untrusted@localhost;
297
--echo BUG#32580: mysqlbinlog cannot read binlog event with user variables
299
# Testing that various kinds of events can be read and restored properly.
303
SET BINLOG_FORMAT = STATEMENT;
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;
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);
312
query_vertical SELECT * FROM t1;
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;
321
query_vertical SELECT * FROM t1;
324
--echo End of 5.1 tests