mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-27037 mysqlbinlog emits a warning when reaching EOF before stop-condition
Emit a warning in the event that we finished processing input files before reaching the boundary indicated by --stop-position.
This commit is contained in:
committed by
Dave Gosselin
parent
cc0faa1e3e
commit
242b67f1de
@@ -142,6 +142,7 @@ static char *charset= 0;
|
||||
static uint verbose= 0;
|
||||
|
||||
static ulonglong start_position, stop_position;
|
||||
static const longlong stop_position_default= (longlong)(~(my_off_t)0);
|
||||
#define start_position_mot ((my_off_t)start_position)
|
||||
#define stop_position_mot ((my_off_t)stop_position)
|
||||
|
||||
@@ -1684,8 +1685,8 @@ static struct my_option my_options[] =
|
||||
"Stop reading the binlog at position N. Applies to the last binlog "
|
||||
"passed on the command line.",
|
||||
&stop_position, &stop_position, 0, GET_ULL,
|
||||
REQUIRED_ARG, (longlong)(~(my_off_t)0), BIN_LOG_HEADER_SIZE,
|
||||
(ulonglong)(~(my_off_t)0), 0, 0, 0},
|
||||
REQUIRED_ARG, stop_position_default, BIN_LOG_HEADER_SIZE,
|
||||
(ulonglong)stop_position_default, 0, 0, 0},
|
||||
{"table", 'T', "List entries for just this table (affects only row events).",
|
||||
&table, &table, 0, GET_STR_ALLOC, REQUIRED_ARG,
|
||||
0, 0, 0, 0, 0, 0},
|
||||
@@ -2937,7 +2938,20 @@ static Exit_status dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
|
||||
llstr(old_off,llbuff));
|
||||
goto err;
|
||||
}
|
||||
// file->error == 0 means EOF, that's OK, we break in this case
|
||||
// else file->error == 0 means EOF, that's OK, we break in this case
|
||||
|
||||
/*
|
||||
Emit a warning in the event that we finished processing input
|
||||
before reaching the boundary indicated by --stop-position.
|
||||
*/
|
||||
if (((longlong)stop_position != stop_position_default) &&
|
||||
stop_position > my_b_tell(file))
|
||||
{
|
||||
retval = OK_STOP;
|
||||
warning("Did not reach stop position %llu before "
|
||||
"end of input", stop_position);
|
||||
}
|
||||
|
||||
goto end;
|
||||
}
|
||||
if ((retval= process_event(print_event_info, ev, old_off, logname)) !=
|
||||
|
@@ -0,0 +1,13 @@
|
||||
|
||||
# MDEV-27037 mysqlbinlog emits a warning when reaching EOF before stop-condition
|
||||
|
||||
Case: Default stop position, WARNING must not appear
|
||||
# MYSQL_BINLOG --short-form --start-position=4 mysql-test/std_data/master-bin.000001 --result-file=warn_pos_test_file.out 2>&1
|
||||
Case: Stop position before EOF, WARNING must not appear
|
||||
# MYSQL_BINLOG --short-form --start-position=4 --stop-position=97 mysql-test/std_data/master-bin.000001 --result-file=warn_pos_test_file.out 2>&1
|
||||
Case: Stop position at EOF, WARNING must not appear
|
||||
# MYSQL_BINLOG --short-form --start-position=4 --stop-position=98 mysql-test/std_data/master-bin.000001 --result-file=warn_pos_test_file.out 2>&1
|
||||
Case: Stop position after EOF, WARNING must appear
|
||||
# MYSQL_BINLOG --short-form --start-position=4 --stop-position=99 mysql-test/std_data/master-bin.000001 --result-file=warn_pos_test_file.out 2>&1
|
||||
WARNING: Did not reach stop position 99 before end of input
|
||||
# End of binlog_mysqlbinlog_warn_stop_position.test
|
@@ -0,0 +1,26 @@
|
||||
--echo
|
||||
--echo # MDEV-27037 mysqlbinlog emits a warning when reaching EOF before stop-condition
|
||||
--echo
|
||||
|
||||
--let assert_file= $MYSQLTEST_VARDIR/tmp/warn_pos_test_file.out
|
||||
--let data_file= $MYSQLTEST_VARDIR/std_data/master-bin.000001
|
||||
|
||||
--echo Case: Default stop position, WARNING must not appear
|
||||
--echo # MYSQL_BINLOG --short-form --start-position=4 mysql-test/std_data/master-bin.000001 --result-file=warn_pos_test_file.out 2>&1
|
||||
--exec $MYSQL_BINLOG --short-form --start-position=4 $data_file --result-file=$assert_file 2>&1
|
||||
|
||||
--echo Case: Stop position before EOF, WARNING must not appear
|
||||
--echo # MYSQL_BINLOG --short-form --start-position=4 --stop-position=97 mysql-test/std_data/master-bin.000001 --result-file=warn_pos_test_file.out 2>&1
|
||||
--exec $MYSQL_BINLOG --short-form --start-position=4 --stop-position=97 $data_file --result-file=$assert_file 2>&1
|
||||
|
||||
--echo Case: Stop position at EOF, WARNING must not appear
|
||||
--echo # MYSQL_BINLOG --short-form --start-position=4 --stop-position=98 mysql-test/std_data/master-bin.000001 --result-file=warn_pos_test_file.out 2>&1
|
||||
--exec $MYSQL_BINLOG --short-form --start-position=4 --stop-position=98 $data_file --result-file=$assert_file 2>&1
|
||||
|
||||
--echo Case: Stop position after EOF, WARNING must appear
|
||||
--echo # MYSQL_BINLOG --short-form --start-position=4 --stop-position=99 mysql-test/std_data/master-bin.000001 --result-file=warn_pos_test_file.out 2>&1
|
||||
--exec $MYSQL_BINLOG --short-form --start-position=4 --stop-position=99 $data_file --result-file=$assert_file 2>&1
|
||||
|
||||
--remove_file $assert_file
|
||||
|
||||
--echo # End of binlog_mysqlbinlog_warn_stop_position.test
|
Reference in New Issue
Block a user