diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 1fe3dc86b35812e12b7aef28316857a4d4e5dd2d..75b875b4f4e2adb9e60188ab4df613bf997a85a4 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -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, diff --git a/sql/log_event.cc b/sql/log_event.cc index b627636186b7fb9dda9479dce94516ce6399fb11..05d5788f5ae1f0d50ea9a3b855db87058de4eb89 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -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) { diff --git a/sql/log_event.h b/sql/log_event.h index 5b9f30b3afd322a7a7858d19b2be0a3da05b2611..b46f78d2ce05f226265bb66f6d03c2aa026fe96b 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -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 @@ public: 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 */