mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
BUG#34141: mysqlbinlog cannot read 4.1 binlogs containing load data infile
Main problem: mysql 5.1 cannot read binlogs from 4.1. Subproblem 1: There is a mistake in sql_ex_info::init. The read_str() function updates its first argument to point to the next character to read. However, it is applied only to a copy of the buffer pointer, so the real buffer pointer is not updated. Fix 1: do not take a copy of the buffer pointer. The copy was needed because sql_ex_info::init does not use the const attribute on some of its arguments. So we add the const attribute, too. Subproblem 2: The first BINLOG statement is asserted to be a FORMAT_DESCRIPTION_LOG_EVENT, but 4.1 binlogs begin with START_EVENT_V3. Fix 2: allow START_EVENT_V3 too. mysql-test/suite/binlog/std_data/binlog_old_version_4_1.000001: New BitKeeper file ``mysql-test/suite/binlog/std_data/binlog_old_version_4_1.000001'' mysql-test/suite/binlog/r/binlog_old_versions.result: Updated result file. mysql-test/suite/binlog/t/binlog_old_versions.test: Added a test reading an old 4.1 binlog. sql/log_event.cc: 1. Added const keyword at the following places: - input buffer for pretty_print_str - input buffer for write_str - input buffer, end pointer, and return value from sql_ex_info::init 2. Fixed the bug by not taking a copy of buf before calling read_str in sql_ex_info::init(). sql/log_event.h: Added const keyword to fields of the sql_ex_info struct. Added const keyword to arguments and return value of sql_ex_info::init sql/sql_binlog.cc: The first BINLOG statement must describe the format for future BINLOG statements. Otherwise, we do not know how to read the BINLOG statement. Problem: only FORMAT_DESCRIPTION_EVENT is currently allowed as the first event. Binlogs from 4.1 begin with a START_EVENT_V3, which serves the same purpose. Fix: We now allow the first BINLOG statement to be a START_EVENT_V3, as well as a FORMAT_DESCRIPTION_EVENT.
This commit is contained in:
@ -159,14 +159,13 @@ void mysql_client_binlog_statement(THD* thd)
|
||||
*/
|
||||
if (!have_fd_event)
|
||||
{
|
||||
if (bufptr[EVENT_TYPE_OFFSET] == FORMAT_DESCRIPTION_EVENT)
|
||||
int type = bufptr[EVENT_TYPE_OFFSET];
|
||||
if (type == FORMAT_DESCRIPTION_EVENT || type == START_EVENT_V3)
|
||||
have_fd_event= TRUE;
|
||||
else
|
||||
{
|
||||
my_error(ER_NO_FORMAT_DESCRIPTION_EVENT_BEFORE_BINLOG_STATEMENT,
|
||||
MYF(0),
|
||||
Log_event::get_type_str(
|
||||
(Log_event_type)bufptr[EVENT_TYPE_OFFSET]));
|
||||
MYF(0), Log_event::get_type_str((Log_event_type)type));
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user