--- /dev/null +++ b/mysql-test/r/percona_bug933969.result @@ -0,0 +1,16 @@ +RESET MASTER; +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (word VARCHAR(20)); +INSERT INTO t1 VALUES ("hamite"); +INSERT INTO t1 VALUES ("hoho"); +INSERT INTO t1 VALUES ("znamenito"); +INSERT INTO t1 VALUES ("mrachny"); +INSERT INTO t1 VALUES ("mrak"); +INSERT INTO t1 VALUES ("zhut"); +INSERT INTO t1 VALUES ("parnisha"); +INSERT INTO t1 VALUES ("krrasota!"); +INSERT INTO t1 VALUES ("podumayesh"); +INSERT INTO t1 VALUES ("ogo!"); +FLUSH LOGS; +DROP TABLE t1; +RESET MASTER; --- /dev/null +++ b/mysql-test/t/percona_bug933969.test @@ -0,0 +1,42 @@ +###################### percona_bug933969.test ######################## +# Bug #933969: mysqlbinlog doesn't accept stdin # +# # +# The goal of this testcase is to test that mysqlbinlog handle # +# stdin correctly when stdin is pipe. # +# i.e. "cat log | mysqlbinlog -" don't cause mysqlbinlog failure # +###################################################################### +-- source include/have_log_bin.inc +-- source include/not_windows.inc +-- source include/not_embedded.inc + +# deletes all the binary logs +RESET MASTER; + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +# produce some statements for binlog + +CREATE TABLE t1 (word VARCHAR(20)); + +INSERT INTO t1 VALUES ("hamite"); +INSERT INTO t1 VALUES ("hoho"); +INSERT INTO t1 VALUES ("znamenito"); +INSERT INTO t1 VALUES ("mrachny"); +INSERT INTO t1 VALUES ("mrak"); +INSERT INTO t1 VALUES ("zhut"); +INSERT INTO t1 VALUES ("parnisha"); +INSERT INTO t1 VALUES ("krrasota!"); +INSERT INTO t1 VALUES ("podumayesh"); +INSERT INTO t1 VALUES ("ogo!"); + +FLUSH LOGS; + +# run mysqlbinlog and make sure it ends normally + +let $MYSQLD_DATADIR= `SELECT @@datadir`; +--system cat $MYSQLD_DATADIR/master-bin.000001 | $MYSQL_BINLOG - >/dev/null + +DROP TABLE t1; +RESET MASTER; --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -1760,7 +1760,7 @@ } pos= my_b_tell(file); - my_b_seek(file, (my_off_t)0); + DBUG_ASSERT(pos == 0); if (my_b_read(file, header, sizeof(header))) { error("Failed reading header; probably an empty file."); @@ -1920,7 +1920,7 @@ /* read from normal file */ if ((fd = my_open(logname, O_RDONLY | O_BINARY, MYF(MY_WME))) < 0) return ERROR_STOP; - if (init_io_cache(file, fd, 0, READ_CACHE, start_position_mot, 0, + if (init_io_cache(file, fd, 0, READ_CACHE, (my_off_t) 0, 0, MYF(MY_WME | MY_NABP))) { my_close(fd, MYF(MY_WME)); @@ -1928,6 +1928,7 @@ } if ((retval= check_header(file, print_event_info, logname)) != OK_CONTINUE) goto end; + my_b_seek(file, start_position_mot); } else {