Commit 1a5c8be4 authored by guilhem@mysql.com's avatar guilhem@mysql.com

Fix for BUG#1096 which is:

"mysqlbinlog does not comment the original LOAD DATA INFILE if it has a "use xx""
parent 83f35b8a
...@@ -613,7 +613,13 @@ Could not read entry at offset %s : Error in log format or read error", ...@@ -613,7 +613,13 @@ Could not read entry at offset %s : Error in log format or read error",
continue; // next 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); load_processor.process(ce);
ev= 0; ev= 0;
break; break;
......
...@@ -1279,6 +1279,11 @@ int Load_log_event::copy_log_event(const char *buf, ulong event_len, ...@@ -1279,6 +1279,11 @@ int Load_log_event::copy_log_event(const char *buf, ulong event_len,
#ifdef MYSQL_CLIENT #ifdef MYSQL_CLIENT
void Load_log_event::print(FILE* file, bool short_form, char* last_db) 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) if (!short_form)
{ {
...@@ -1295,9 +1300,12 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db) ...@@ -1295,9 +1300,12 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db)
} }
if (db && db[0] && !same_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()) if (check_fname_outside_temp_buf())
fprintf(file, "LOCAL "); fprintf(file, "LOCAL ");
fprintf(file, "INFILE '%-*s' ", fname_len, fname); fprintf(file, "INFILE '%-*s' ", fname_len, fname);
...@@ -1573,9 +1581,11 @@ void Create_file_log_event::print(FILE* file, bool short_form, ...@@ -1573,9 +1581,11 @@ void Create_file_log_event::print(FILE* file, bool short_form,
if (enable_local) if (enable_local)
{ {
if (!check_fname_outside_temp_buf()) Load_log_event::print(file, 1, last_db, !check_fname_outside_temp_buf());
fprintf(file, "#"); /*
Load_log_event::print(file, 1, last_db); That one is for "file_id: etc" below: in mysqlbinlog we want the #, in
SHOW BINLOG EVENTS we don't.
*/
fprintf(file, "#"); fprintf(file, "#");
} }
......
...@@ -435,6 +435,7 @@ class Load_log_event: public Log_event ...@@ -435,6 +435,7 @@ class Load_log_event: public Log_event
bool use_rli_only_for_errors); bool use_rli_only_for_errors);
#else #else
void print(FILE* file, bool short_form = 0, char* last_db = 0); 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 #endif
Load_log_event(const char* buf, int event_len, bool old_format); Load_log_event(const char* buf, int event_len, bool old_format);
......
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