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_statement.inc
4
5-- source include/have_log_bin.inc
6-- source include/binlog_start_pos.inc
7
8--disable_query_log
9CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
10--enable_query_log
11
12# Deletes all the binary logs
13reset master;
14
15# we need this for getting fixed timestamps inside of this test
16set timestamp=1000000000;
17
18--disable_warnings
19drop table if exists t1,t2,t3,t4,t5,t03,t04;
20--enable_warnings
21
22create table t1 (word varchar(20));
23create table t2 (id int auto_increment not null primary key);
24
25# simple test for simple statement and various events
26insert into t1 values ("abirvalg");
27insert into t2 values ();
28# Should be uncommented in 4.1
29# set @a:=1
30# insert into t2 values (@a);
31
32# test for load data and load data distributed among the several
33# files (we need to fill up first binlog)
34load data infile '../../std_data/words3.dat' into table t1;
35load data infile '../../std_data/words3.dat' into table t1;
36load data infile '../../std_data/words3.dat' into table t1;
37load data infile '../../std_data/words3.dat' into table t1;
38load data infile '../../std_data/words3.dat' into table t1;
39# simple query to show more in second binlog
40--let $binlog_start_pos=query_get_value(SHOW MASTER STATUS, Position, 1)
41insert into t1 values ("Alas");
42
43### Starting master-bin.000003
44flush logs;
45
46# delimiters are for easier debugging in future
47--disable_query_log
48select "--- Local --" as "";
49--enable_query_log
50
51#
52# We should use --short-form everywhere because in other case output will
53# be time dependend. Better than nothing.
54#
55let $MYSQLD_DATADIR= `select @@datadir`;
56--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
57--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/
58--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000001
59
60# this should not fail but shouldn't produce any working statements
61--disable_query_log
62select "--- Broken LOAD DATA --" as "";
63--enable_query_log
64--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
65--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/
66--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000002 2> /dev/null
67
68# this should show almost nothing
69--disable_query_log
70select "--- --database --" as "";
71--enable_query_log
72--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
73--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/
74--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --database=nottest $MYSQLD_DATADIR/master-bin.000001 2> /dev/null
75
76# this test for start-position option
77--disable_query_log
78select "--- --start-position --" as "";
79--enable_query_log
80--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
81--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/
82--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --start-position=$binlog_start_pos $MYSQLD_DATADIR/master-bin.000002
83
84# These are tests for remote binlog.
85# They should return the same as previous test.
86
87--disable_query_log
88select "--- Remote --" as "";
89--enable_query_log
90
91# This is broken now
92--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
93--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/
94--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
95
96# This is broken too
97--disable_query_log
98select "--- Broken LOAD DATA --" as "";
99--enable_query_log
100--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
101--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/
102--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
103
104# And this too ! (altough it is documented)
105--disable_query_log
106select "--- --database --" as "";
107--enable_query_log
108--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
109--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/
110--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
111
112# Strangely but this works
113--disable_query_log
114select "--- --start-position --" as "";
115--enable_query_log
116--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
117--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/
118--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --start-position=$binlog_start_pos --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
119
120# Bug#7853 mysqlbinlog does not accept input from stdin
121--disable_query_log
122select "--- reading stdin --" as "";
123--enable_query_log
124--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
125--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/
126--exec $MYSQL_BINLOG --short-form - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001
127
128--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
129--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/
130# postion is constant to correspond to an event in pre-recorded binlog
131--let $binlog_start_pos=79
132--exec $MYSQL_BINLOG --short-form --start-position=$binlog_start_pos - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001
133
134drop table t1,t2;
135
136#
137# Bug#14157 utf8 encoding in binlog without set character_set_client
138#
139### Starting master-bin.000004
140flush logs;
141
142--write_file $MYSQLTEST_VARDIR/tmp/bug14157.sql
143create table if not exists t5 (a int);
144set names latin1;
145create temporary table `������` (a int);
146insert into `������` values (1);
147insert into t5 select * from `������`
148EOF
149--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug14157.sql
150--remove_file $MYSQLTEST_VARDIR/tmp/bug14157.sql
151
152# resulted binlog, parly consisting of multi-byte utf8 chars,
153# must be digestable for both client and server. In 4.1 the client
154# should use default-character-set same as the server.
155
156### Starting master-bin.000005
157flush logs;
158# Due to BUG#18337 that wrongly suppresses the BINLOG EVENTS when
159# --short-form is used, the "insert into t5 select * from `������`"
160# which is unsafe and thus written to the binary log in the row
161# format is not executed. This makes the assertion select * from t5
162# /* must be (1),(1) */; to fail. To temporary fix the bug, we
163# removed the option --short-form.
164#--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000004 | $MYSQL
165--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000004 | $MYSQL
166select * from t5  /* must be (1),(1) */;
167drop table t5;
168
169#
170# Bug#22645 LC_TIME_NAMES: Statement not replicated
171# Check that a dump created by mysqlbinlog reproduces
172# lc_time_names dependent values correctly
173#
174
175### Starting master-bin.000006
176flush logs;
177create table t5 (c1 int, c2 varchar(128) character set latin1 not null);
178insert into t5 values (1, date_format('2001-01-01','%W'));
179set lc_time_names=de_DE;
180insert into t5 values (2, date_format('2001-01-01','%W'));
181set lc_time_names=en_US;
182insert into t5 values (3, date_format('2001-01-01','%W'));
183select * from t5 order by c1;
184
185### Starting master-bin.000007
186flush logs;
187
188drop table t5;
189--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000006 | $MYSQL
190select * from t5 order by c1;
191drop table t5;
192
193#
194# Bug#20396 Bin Log does not get DELIMETER cmd - Recover StoredProc fails
195#
196--disable_warnings
197drop procedure if exists p1;
198--enable_warnings
199
200### Starting master-bin.000008
201flush logs;
202
203delimiter //;
204create procedure p1()
205begin
206select 1;
207end;
208//
209delimiter ;//
210
211### Starting master-bin.000009
212flush logs;
213
214call p1();
215drop procedure p1;
216--error ER_SP_DOES_NOT_EXIST
217call p1();
218--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/
219--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000008
220--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000008 | $MYSQL
221call p1();
222drop procedure p1;
223
224#
225# Some coverage of not normally used parts
226#
227--disable_query_log
228--exec $MYSQL_BINLOG --version 2>&1 > /dev/null
229--exec $MYSQL_BINLOG --help 2>&1 > /dev/null
230--enable_query_log
231
232#
233# Bug#15126 character_set_database is not replicated
234# (LOAD DATA INFILE need it)
235#
236
237### Starting master-bin.000010
238flush logs;
239
240create table t1 (a varchar(64) character set utf8);
241load data infile '../../std_data/loaddata6.dat' into table t1;
242set character_set_database=koi8r;
243load data infile '../../std_data/loaddata6.dat' into table t1;
244set character_set_database=latin1;
245load data infile '../../std_data/loaddata6.dat' into table t1;
246load data infile '../../std_data/loaddata6.dat' into table t1;
247set character_set_database=koi8r;
248load data infile '../../std_data/loaddata6.dat' into table t1;
249set character_set_database=latin1;
250load data infile '../../std_data/loaddata6.dat' into table t1;
251load data infile '../../std_data/loaddata6.dat' into table t1 character set koi8r;
252select hex(a) from t1;
253drop table t1;
254
255### Starting master-bin.000011
256flush logs;
257
258--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
259--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/
260--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000010
261
262#
263# Bug#28293 missed '#' sign in the hex dump when the dump length
264#           is divisible by 16.
265#
266
267CREATE TABLE t1 (c1 CHAR(10));
268# we need this for getting fixed timestamps inside of this test
269### Starting master-bin.000012
270FLUSH LOGS;
271
272INSERT INTO t1 VALUES ('0123456789');
273
274### Starting master-bin.000013
275FLUSH LOGS;
276
277DROP TABLE t1;
278
279# We create a table named "patch", and load the output into it.
280# By using LIKE, we can easily see if the output is missing the '#'
281# character, as described in the bug.
282
283--disable_query_log
284CREATE TABLE patch (a BLOB);
285--exec $MYSQL_BINLOG --hexdump --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000012 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_tmp.dat
286### Starting master-bin.000014
287eval LOAD DATA LOCAL INFILE '$MYSQLTEST_VARDIR/tmp/mysqlbinlog_tmp.dat'
288     INTO TABLE patch FIELDS TERMINATED BY '';
289--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_tmp.dat
290--enable_query_log
291
292--echo We expect this value to be 2 (one for the INSERT, one for COMMIT).
293--echo The bug being tested was that 'Query' lines were not preceded by '#'
294--echo If the line is in the table, it had to have been preceded by a '#'
295--echo
296SELECT COUNT(*) AS `BUG#28293_expect_2` FROM patch WHERE a LIKE '#%Query%';
297DROP TABLE patch;
298
299#
300# Bug#29928 incorrect connection_id() restoring from mysqlbinlog out
301#
302### Starting master-bin.000015
303FLUSH LOGS;
304
305CREATE TABLE t1(a INT);
306INSERT INTO t1 VALUES(connection_id());
307let $a= `SELECT a FROM t1`;
308
309### Starting master-bin.000016
310FLUSH LOGS;
311
312let $outfile= $MYSQLTEST_VARDIR/tmp/bug29928.sql;
313--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000015 > $outfile
314DROP TABLE t1;
315connect (con1, localhost, root, , test);
316connection con1;
317--exec $MYSQL test < $outfile
318--remove_file $outfile
319let $b= `SELECT a FROM t1`;
320disconnect con1;
321connection default;
322let $c= `SELECT $a=$b`;
323--echo $c
324DROP TABLE t1;
325
326echo shell> mysqlbinlog std_data/corrupt-relay-bin.000624 > var/tmp/bug31793.sql;
327error 1;
328exec $MYSQL_BINLOG $MYSQL_TEST_DIR/std_data/corrupt-relay-bin.000624 > $MYSQLTEST_VARDIR/tmp/bug31793.sql;
329--remove_file $MYSQLTEST_VARDIR/tmp/bug31793.sql
330
331#
332# Test --disable-force-if-open and --force-if-open
333#
334### Starting master-bin.000017
335FLUSH LOGS;
336
337--error 1
338--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000017 >/dev/null 2>/dev/null
339--exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/master-bin.000017 >/dev/null 2>/dev/null
340
341--echo Bug#31611 Security risk with BINLOG statement
342
343SET BINLOG_FORMAT=ROW;
344CREATE DATABASE mysqltest1;
345CREATE USER untrusted@localhost;
346GRANT SELECT ON mysqltest1.* TO untrusted@localhost;
347
348SHOW GRANTS FOR untrusted@localhost;
349USE mysqltest1;
350CREATE TABLE t1 (a INT, b CHAR(64));
351
352### Starting master-bin.000018
353flush logs;
354
355INSERT INTO t1 VALUES (1,USER());
356
357### Starting master-bin.000019
358flush logs;
359echo mysqlbinlog var/log/master-bin.000018 > var/tmp/bug31611.sql;
360exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000018 > $MYSQLTEST_VARDIR/tmp/bug31611.sql;
361connect (unsecure,localhost,untrusted,,mysqltest1);
362echo mysql mysqltest1 -uuntrusted < var/tmp/bug31611.sql;
363error 1;
364exec $MYSQL mysqltest1 -uuntrusted < $MYSQLTEST_VARDIR/tmp/bug31611.sql;
365--remove_file $MYSQLTEST_VARDIR/tmp/bug31611.sql
366connection unsecure;
367error ER_TABLEACCESS_DENIED_ERROR;
368INSERT INTO t1 VALUES (1,USER());
369
370SELECT * FROM t1;
371connection default;
372DROP DATABASE mysqltest1;
373DROP USER untrusted@localhost;
374
375--echo Bug#32580 mysqlbinlog cannot read binlog event with user variables
376
377# Testing that various kinds of events can be read and restored properly.
378
379connection default;
380USE test;
381SET BINLOG_FORMAT = STATEMENT;
382
383### Starting master-bin.000020
384FLUSH LOGS;
385
386CREATE TABLE t1 (a_real FLOAT, an_int INT, a_decimal DECIMAL(5,2), a_string CHAR(32));
387SET @a_real = rand(20) * 1000;
388SET @an_int = 1000;
389SET @a_decimal = CAST(rand(19) * 999 AS DECIMAL(5,2));
390SET @a_string = 'Just a test';
391INSERT INTO t1 VALUES (@a_real, @an_int, @a_decimal, @a_string);
392
393### Starting master-bin.000021
394FLUSH LOGS;
395
396query_vertical SELECT * FROM t1;
397DROP TABLE t1;
398
399echo >> mysqlbinlog var/log/master-bin.000020 > var/tmp/bug32580.sql;
400exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000020 > $MYSQLTEST_VARDIR/tmp/bug32580.sql;
401echo >> mysql test < var/tmp/bug32580.sql;
402exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug32580.sql;
403remove_file $MYSQLTEST_VARDIR/tmp/bug32580.sql;
404
405query_vertical SELECT * FROM t1;
406DROP TABLE t1;
407
408#
409# Bug#37313 BINLOG Contains Incorrect server id
410#
411
412let $binlog_file=  $MYSQLTEST_VARDIR/tmp/mysqlbinlog_bug37313.binlog;
413let $save_server_id= `SELECT @@global.server_id`;
414let $s_id_max= `SELECT (1 << 32) - 1`;
415eval SET @@global.server_id= $s_id_max;
416
417RESET MASTER;
418FLUSH LOGS;
419
420--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $binlog_file
421--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
422eval SELECT
423(@a:=LOAD_FILE("$binlog_file"))
424IS NOT NULL;
425let $s_id_unsigned= `SELECT @a LIKE "%server id $s_id_max%" /* must return 1 */`;
426echo *** Unsigned server_id $s_id_max is found: $s_id_unsigned ***;
427
428eval SET @@global.server_id= $save_server_id;
429--remove_file $binlog_file
430
431#
432# Bug #41943: mysqlbinlog.exe crashes if --hexdump option is used
433#
434
435RESET MASTER;
436FLUSH LOGS;
437
438# We do not need the results, just make sure that mysqlbinlog does not crash
439--exec $MYSQL_BINLOG --hexdump --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT  master-bin.000001 >/dev/null
440
441#
442# #46998
443# This test verifies if the 'BEGIN', 'COMMIT' and 'ROLLBACK' are output
444# in regardless of database filtering
445#
446
447RESET MASTER;
448FLUSH LOGS;
449
450# The following three test cases were wrtten into binlog_transaction.000001
451# Test case1: Test if the 'BEGIN' and 'COMMIT' are output for the 'test' database
452# in transaction1 base on innodb engine tables
453# use test;
454# create table t1(a int) engine= innodb;
455# use mysql;
456# create table t2(a int) engine= innodb;
457# Transaction1 begin
458# begin;
459# use test;
460# insert into t1 (a) values (1);
461# use mysql;
462# insert into t2 (a) values (1);
463# commit;
464# Transaction1 end
465
466# Test case2: Test if the 'BEGIN' and 'ROLLBACK' are output for the 'test' database
467# in transaction2 base on innodb and myisam engine tables
468# use test;
469# create table t3(a int) engine= innodb;
470# use mysql;
471# create table t4(a int) engine= myisam;
472# Transaction2 begin
473# begin;
474# use test;
475# insert into t3 (a) values (2);
476# use mysql;
477# insert into t4 (a) values (2);
478# rollback;
479# Transaction2 end
480
481--echo #
482--echo # Test if the 'BEGIN', 'ROLLBACK' and 'COMMIT' are output if the database specified exists
483--exec $MYSQL_BINLOG --database=test --short-form $MYSQLTEST_VARDIR/std_data/binlog_transaction.000001
484--echo #
485--echo # Test if the 'BEGIN', 'ROLLBACK' and 'COMMIT' are output if the database specified does not exist
486--exec $MYSQL_BINLOG --database=not_exist --short-form $MYSQLTEST_VARDIR/std_data/binlog_transaction.000001
487
488--echo #
489--echo # Test if the 'SAVEPOINT', 'ROLLBACK TO' are output if the database specified exists
490--exec $MYSQL_BINLOG --database=db1 --short-form $MYSQLTEST_VARDIR/std_data/binlog_savepoint.000001
491--echo #
492--echo # Test if the 'SAVEPOINT', 'ROLLBACK TO' are output if the database specified does not exist
493--exec $MYSQL_BINLOG --database=not_exist --short-form $MYSQLTEST_VARDIR/std_data/binlog_savepoint.000001
494
495--echo End of 5.0 tests
496
497--echo End of 5.1 tests
498
499#
500# BUG#38468 Memory leak detected when using mysqlbinlog utility;
501#
502disable_query_log;
503RESET MASTER;
504CREATE TABLE t1 SELECT 1;
505FLUSH LOGS;
506DROP TABLE t1;
507enable_query_log;
508
509# Write an empty file for comparison
510write_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn.empty;
511EOF
512
513# Before fix of BUG#38468, this would generate some warnings
514--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 >/dev/null 2> $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn
515
516# Make sure the command above does not generate any error or warnings
517diff_files $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn.empty;
518
519# Cleanup for this part of test
520remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn.empty;
521remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn;
522
523#
524# MDEV-25222: Remove mysqlbinlog options --base64-output=always and --base64-output
525#
526--echo #
527--echo # Expect error for invalid --base64-output argument value.
528--echo # MYSQL_BINLOG std_data/master-bin.000001 --base64-output=always 2>&1
529--error 1
530--exec $MYSQL_BINLOG std_data/master-bin.000001 --base64-output=always 2>&1
531
532--echo #
533--echo # Expect error for incomplete --base64-output argument.
534--echo # MYSQL_BINLOG  std_data/master-bin.000001 --base64-output 2>&1
535# The error produces the absolute path of the mysqlbinlog executable, remove it.
536--replace_regex /.*mysqlbinlog.*:/mysqlbinlog:/i
537--error 1
538--exec $MYSQL_BINLOG std_data/master-bin.000001 --base64-output 2>&1
539
540--echo #
541--echo # Ensure --base64-output=auto outputs the same result as unspecified
542--echo # MYSQL_BINLOG -v MYSQLD_DATADIR/master-bin.000001 > MYSQLTEST_VARDIR/tmp/mysqlbinlog_nob64spec.out
543--exec  $MYSQL_BINLOG -v $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_nob64spec.out
544--echo # MYSQL_BINLOG --base64-output=auto -v MYSQLD_DATADIR/master-bin.000001 > MYSQLTEST_VARDIR/tmp/mysqlbinlog_b64auto.out
545--exec  $MYSQL_BINLOG --base64-output=auto -v $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_b64auto.out
546--diff_files $MYSQLTEST_VARDIR/tmp/mysqlbinlog_nob64spec.out $MYSQLTEST_VARDIR/tmp/mysqlbinlog_b64auto.out
547--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_nob64spec.out
548--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_b64auto.out
549
550
551# BUG#50914
552# This test verifies if the approach of the mysqlbinlog prints
553# "use $database" statements to its output stream will cause
554# "No Database Selected" error when dropping and recreating
555# that database.
556#
557RESET MASTER;
558CREATE DATABASE test1;
559USE test1;
560CREATE TABLE t1(id int);
561DROP DATABASE test1;
562CREATE DATABASE test1;
563USE test1;
564CREATE TABLE t1(id int);
565DROP TABLE t1;
566DROP DATABASE test1;
567let $master_binlog= query_get_value(SHOW MASTER STATUS, File, 1);
568FLUSH LOGS;
569--source include/wait_for_binlog_checkpoint.inc
570
571let $MYSQLD_DATADIR= `SELECT @@datadir`;
572exec $MYSQL_BINLOG $MYSQLD_DATADIR/$master_binlog | $MYSQL test 2>&1;
573
574let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
575source include/show_binlog_events.inc;
576
577#
578# BUG#11766427 BUG#59530: Filter by server id in mysqlbinlog fails
579# This test checks that the format description log event is not
580# filtered out by the --server-id option.
581#
582RESET MASTER;
583USE test;
584CREATE TABLE t1 (a INT);
585--let $old_server_id= `SELECT @@GLOBAL.SERVER_ID`
586SET GLOBAL SERVER_ID = 2;
587DROP TABLE t1;
588--let $master_binlog= query_get_value(SHOW MASTER STATUS, File, 1)
589FLUSH LOGS;
590# The following should only create t1, not drop it.
591--exec $MYSQL_BINLOG --server-id=1 $MYSQLD_DATADIR/$master_binlog | $MYSQL
592SHOW TABLES IN test;
593# The following should only drop t1, not create it.
594--exec $MYSQL_BINLOG --server-id=2 $MYSQLD_DATADIR/$master_binlog | $MYSQL
595SHOW TABLES IN test;
596eval SET GLOBAL SERVER_ID = $old_server_id;
597
598--echo #
599--echo # MDEV-4645: Incorrect reads of frozen binlog events;
600--echo # FDE corrupted in relay log
601--echo #
602--let TZ=GMT
603--exec $MYSQL_BINLOG --hexdump std_data/mdev-4645-binlog_checksum.binlog
604--exec $MYSQL_BINLOG --hexdump std_data/mdev-4645-binlog_group_id.binlog
605--exec $MYSQL_BINLOG --hexdump std_data/mdev-4645-binlog_group_id_checksum.binlog
606--exec $MYSQL_BINLOG --hexdump std_data/mdev-4645-binlog_none.binlog
607
608#
609# MDEV-12372 mysqlbinlog --version output is the same on 10.x as on 5.5.x, and contains not only version
610#
611replace_regex /.*mysqlbinlog(\.exe)? Ver .* for .* at [-_a-zA-Z0-9]+/mysqlbinlog Ver VER for OS at ARCH/;
612exec $MYSQL_BINLOG --version;
613
614--echo #
615--echo # Test --rewrite-db
616--echo #
617
618RESET MASTER;
619CREATE TABLE t1 (a int);
620INSERT INTO t1 values(1);
621DROP TABLE t1;
622FLUSH LOGS;
623
624--error 1
625--exec $MYSQL_BINLOG --rewrite-db=a --short-form $MYSQLD_DATADIR/master-bin.000001 2>&1
626
627--error 1
628--exec $MYSQL_BINLOG --rewrite-db="a->" --short-form $MYSQLD_DATADIR/master-bin.000001 2>&1
629
630--error 1
631--exec $MYSQL_BINLOG --rewrite-db="a-> " --short-form $MYSQLD_DATADIR/master-bin.000001 2>&1
632
633--error 1
634--exec $MYSQL_BINLOG --rewrite-db="->b" --short-form $MYSQLD_DATADIR/master-bin.000001 2>&1
635
636--error 1
637--exec $MYSQL_BINLOG --rewrite-db=" ->" --short-form $MYSQLD_DATADIR/master-bin.000001 2>&1
638
639--exec $MYSQL_BINLOG --rewrite-db=" test -> foo " --short-form $MYSQLD_DATADIR/master-bin.000001 > /dev/null 2> $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn
640