Task 761:'mysqlbinlog should not die when reading

unknown event'
parent 767f9a52
......@@ -43,6 +43,7 @@ static const char* default_dbug_option = "d:t:o,/tmp/mysqlbinlog.trace";
void sql_print_error(const char *format, ...);
static bool one_database = 0;
static bool force_opt= 0;
static const char* database;
static bool short_form = 0;
static ulonglong offset = 0;
......@@ -73,6 +74,9 @@ static struct my_option my_long_options[] =
{"database", 'd', "List entries for just this database (local log only)",
(gptr*) &database, (gptr*) &database, 0, GET_STR_ALLOC, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{"force-read", 'f', "Force reading unknown binlog events",
(gptr*) &force_opt, (gptr*) &force_opt, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
0, 0},
{"help", '?', "Display this help and exit",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"host", 'h', "Get the binlog from server", (gptr*) &host, (gptr*) &host,
......
......@@ -659,9 +659,18 @@ Log_event* Log_event::read_log_event(const char* buf, int event_len,
}
if (!ev || !ev->is_valid())
{
*error= "Found invalid event in binary log";
delete ev;
#ifdef MYSQL_CLIENT
if (!force_opt)
{
*error= "Found invalid event in binary log";
return 0;
}
ev= new Unknown_log_event(buf, old_format);
#else
*error= "Found invalid event in binary log";
return 0;
#endif
}
ev->cached_event_len = event_len;
return ev;
......@@ -1695,6 +1704,17 @@ void Execute_load_log_event::pack_info(String* packet)
}
#endif
#ifdef MYSQL_CLIENT
void Unknown_log_event::print(FILE* file, bool short_form, char* last_db)
{
if (short_form)
return;
print_header(file);
fputc('\n', file);
fprintf(file, "# %s", "Unknown event\n");
}
#endif
#ifndef MYSQL_CLIENT
int Query_log_event::exec_event(struct st_relay_log_info* rli)
{
......
......@@ -201,10 +201,10 @@ struct sql_ex_info
enum Log_event_type
{
START_EVENT = 1, QUERY_EVENT =2, STOP_EVENT=3, ROTATE_EVENT = 4,
INTVAR_EVENT=5, LOAD_EVENT=6, SLAVE_EVENT=7, CREATE_FILE_EVENT=8,
APPEND_BLOCK_EVENT=9, EXEC_LOAD_EVENT=10, DELETE_FILE_EVENT=11,
NEW_LOAD_EVENT=12, RAND_EVENT=13
UNKNOWN_EVENT = 0, START_EVENT = 1, QUERY_EVENT =2, STOP_EVENT=3,
ROTATE_EVENT = 4, INTVAR_EVENT=5, LOAD_EVENT=6, SLAVE_EVENT=7,
CREATE_FILE_EVENT=8, APPEND_BLOCK_EVENT=9, EXEC_LOAD_EVENT=10,
DELETE_FILE_EVENT=11, NEW_LOAD_EVENT=12, RAND_EVENT=13
};
enum Int_event_type
......@@ -714,4 +714,18 @@ class Execute_load_log_event: public Log_event
int write_data(IO_CACHE* file);
};
#ifdef MYSQL_CLIENT
class Unknown_log_event: public Log_event
{
public:
Unknown_log_event(const char* buf, bool old_format):
Log_event(buf, old_format)
{}
~Unknown_log_event() {}
void print(FILE* file, bool short_form= 0, char* last_db= 0);
Log_event_type get_type_code() { return UNKNOWN_EVENT;}
bool is_valid() { return 1; }
};
#endif
#endif /* _log_event_h */
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