Commit 95885261 authored by Dave Gosselin's avatar Dave Gosselin Committed by Dave Gosselin

MDEV-27037 mysqlbinlog emits a warning when reaching EOF before stop-datetime

Emit a warning in the event that we finished processing input files
before reaching the boundary indicated by --stop-datetime.
parent 242b67f1
......@@ -2847,6 +2847,7 @@ static Exit_status dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
IO_CACHE cache,*file= &cache;
uchar tmp_buff[BIN_LOG_HEADER_SIZE];
Exit_status retval= OK_CONTINUE;
my_time_t last_ev_when= MY_TIME_T_MAX;
if (logname && strcmp(logname, "-") != 0)
{
......@@ -2952,8 +2953,21 @@ static Exit_status dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
"end of input", stop_position);
}
/*
Emit a warning in the event that we finished processing input
before reaching the boundary indicated by --stop-datetime.
*/
if (stop_datetime != MY_TIME_T_MAX &&
stop_datetime > last_ev_when)
{
retval = OK_STOP;
warning("Did not reach stop datetime '%s' "
"before end of input", stop_datetime_str);
}
goto end;
}
last_ev_when= ev->when;
if ((retval= process_event(print_event_info, ev, old_off, logname)) !=
OK_CONTINUE)
goto end;
......
# MDEV-27037 mysqlbinlog emits a warning when reaching EOF before stop-datetime
set timestamp=1000000000;
CREATE TABLE t1(word VARCHAR(20));
set timestamp=1000000010;
INSERT INTO t1 VALUES ("abirvalg");
set timestamp=1000000020;
INSERT INTO t1 SELECT * FROM t1;
flush logs;
Case: Default, must not see warning.
# MYSQL_BINLOG --short-form MYSQLD_DATADIR/master-bin.000001 --result-file=ignored_output_file
Case: Stop datetime before EOF, must not see warning.
# MYSQL_BINLOG --short-form --stop-datetime='2001-09-08 21:46:50' MYSQLD_DATADIR/master-bin.000001 --result-file=ignored_output_file
Case: Stop datetime between records, must not see warning.
# MYSQL_BINLOG --short-form --stop-datetime='2001-09-08 21:46:55' MYSQLD_DATADIR/master-bin.000001 --result-file=ignored_output_file
Case: Stop datetime at EOF, must not see warning.
# MYSQL_BINLOG --short-form --stop-datetime='2001-09-08 21:46:55' MYSQLD_DATADIR/master-bin.000001 --result-file=ignored_output_file
Case: Stop datetime after EOF, must see warning.
# MYSQL_BINLOG --short-form --stop-datetime='2035-01-19 03:14:05' MYSQLD_DATADIR/master-bin.000001 --result-file=ignored_output_file
WARNING: Did not reach stop datetime '2035-01-19 03:14:05' before end of input
DROP TABLE t1;
# End of binlog_mysqlbinlog_warn_stop_datetime.test
--echo
--echo # MDEV-27037 mysqlbinlog emits a warning when reaching EOF before stop-datetime
--echo
--source include/have_binlog_format_statement.inc
--let ignored_output_file= $MYSQLTEST_VARDIR/tmp/warn_pos_test_file.out
set timestamp=1000000000;
CREATE TABLE t1(word VARCHAR(20));
set timestamp=1000000010;
INSERT INTO t1 VALUES ("abirvalg");
set timestamp=1000000020;
INSERT INTO t1 SELECT * FROM t1;
--let MYSQLD_DATADIR= `select @@datadir;`
flush logs;
--echo Case: Default, must not see warning.
--echo # MYSQL_BINLOG --short-form MYSQLD_DATADIR/master-bin.000001 --result-file=ignored_output_file
--exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000001 --result-file=$ignored_output_file 2>&1
--echo Case: Stop datetime before EOF, must not see warning.
--echo # MYSQL_BINLOG --short-form --stop-datetime='2001-09-08 21:46:50' MYSQLD_DATADIR/master-bin.000001 --result-file=ignored_output_file
--exec $MYSQL_BINLOG --short-form --stop-datetime='2001-09-08 21:46:50' $MYSQLD_DATADIR/master-bin.000001 --result-file=$ignored_output_file 2>&1
--echo Case: Stop datetime between records, must not see warning.
--echo # MYSQL_BINLOG --short-form --stop-datetime='2001-09-08 21:46:55' MYSQLD_DATADIR/master-bin.000001 --result-file=ignored_output_file
--exec $MYSQL_BINLOG --short-form --stop-datetime='2001-09-08 21:46:55' $MYSQLD_DATADIR/master-bin.000001 --result-file=$ignored_output_file 2>&1
--echo Case: Stop datetime at EOF, must not see warning.
--echo # MYSQL_BINLOG --short-form --stop-datetime='2001-09-08 21:46:55' MYSQLD_DATADIR/master-bin.000001 --result-file=ignored_output_file
--exec $MYSQL_BINLOG --short-form --stop-datetime='2001-09-08 21:46:55' $MYSQLD_DATADIR/master-bin.000001 --result-file=$ignored_output_file 2>&1
--echo Case: Stop datetime after EOF, must see warning.
--echo # MYSQL_BINLOG --short-form --stop-datetime='2035-01-19 03:14:05' MYSQLD_DATADIR/master-bin.000001 --result-file=ignored_output_file
--exec $MYSQL_BINLOG --short-form --stop-datetime='2035-01-19 03:14:05' $MYSQLD_DATADIR/master-bin.000001 --result-file=$ignored_output_file 2>&1
DROP TABLE t1;
--remove_file $ignored_output_file
--echo # End of binlog_mysqlbinlog_warn_stop_datetime.test
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment