diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 954e9290a76..a454d6a859f 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -613,7 +613,13 @@ Could not read entry at offset %s : Error in log format or read error", continue; // next } } - ce->print(result_file, short_form, last_db,true); + /* + We print the event, but with a leading '#': this is just to inform the + user of the original command; the command we want to execute will be a + derivation of this original command (we will change the filename and + use LOCAL), prepared in the 'case EXEC_LOAD_EVENT' below. + */ + ce->print(result_file, short_form, last_db, true); load_processor.process(ce); ev= 0; break; diff --git a/sql/log_event.cc b/sql/log_event.cc index 3451ffab65f..591ebf2b5d8 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1279,6 +1279,11 @@ int Load_log_event::copy_log_event(const char *buf, ulong event_len, #ifdef MYSQL_CLIENT void Load_log_event::print(FILE* file, bool short_form, char* last_db) +{ + print(file, short_form, last_db, 0); +} + +void Load_log_event::print(FILE* file, bool short_form, char* last_db, bool commented) { if (!short_form) { @@ -1295,9 +1300,12 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db) } if (db && db[0] && !same_db) - fprintf(file, "use %s;\n", db); + fprintf(file, "%suse %s;\n", + commented ? "# " : "", + db); - fprintf(file, "LOAD DATA "); + fprintf(file, "%sLOAD DATA ", + commented ? "# " : ""); if (check_fname_outside_temp_buf()) fprintf(file, "LOCAL "); fprintf(file, "INFILE '%-*s' ", fname_len, fname); @@ -1573,10 +1581,12 @@ void Create_file_log_event::print(FILE* file, bool short_form, if (enable_local) { - if (!check_fname_outside_temp_buf()) - fprintf(file, "#"); - Load_log_event::print(file, 1, last_db); - fprintf(file, "#"); + Load_log_event::print(file, 1, last_db, !check_fname_outside_temp_buf()); + /* + That one is for "file_id: etc" below: in mysqlbinlog we want the #, in + SHOW BINLOG EVENTS we don't. + */ + fprintf(file, "#"); } fprintf(file, " file_id: %d block_len: %d\n", file_id, block_len); diff --git a/sql/log_event.h b/sql/log_event.h index 155da07bebd..1031b940528 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -435,6 +435,7 @@ public: bool use_rli_only_for_errors); #else void print(FILE* file, bool short_form = 0, char* last_db = 0); + void print(FILE* file, bool short_form, char* last_db, bool commented); #endif Load_log_event(const char* buf, int event_len, bool old_format);