From 270e2f3c2f1c3c391a5de9311102b5f545923a42 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Feb 2008 20:55:12 +0100 Subject: Replace windows path separator backslash by unix path separator forward slash in filenames also for Create_file_log_event. client/mysqlbinlog.cc: BUG#34355: mysqlbinlog outputs backslash as path separator for 4.1 binlogs Problem: When the windows version of mysqlbinlog reads 4.1 binlogs containing LOAD DATA INFILE, it outputs backslashes as path separators in filenames. However, the output is typically piped to a client, and client expects forward slashes. Fix: Replace '\\' by '/' in filenames. --- client/mysqlbinlog.cc | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'client/mysqlbinlog.cc') diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 0553240894e..b4086b59c01 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -465,6 +465,31 @@ Create_file event for file_id: %u\n",ae->file_id); Load_log_processor load_processor; +/** + Replace windows-style backslashes by forward slashes so it can be + consumed by the mysql client, which requires Unix path. + + @todo This is only useful under windows, so may be ifdef'ed out on + other systems. /Sven + + @todo If a Create_file_log_event contains a filename with a + backslash (valid under unix), then we have problems under windows. + /Sven + + @param[in,out] fname Filename to modify. The filename is modified + in-place. +*/ +static void convert_path_to_forward_slashes(char *fname) +{ + while (*fname) + { + if (*fname == '\\') + *fname= '/'; + fname++; + } +} + + static bool check_database(const char *log_dbname) { return one_database && @@ -582,6 +607,11 @@ int process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, */ if (ce) { + /* + We must not convert earlier, since the file is used by + my_open() in Load_log_processor::append(). + */ + convert_path_to_forward_slashes((char*) ce->fname); ce->print(result_file, print_event_info, TRUE); my_free((char*)ce->fname,MYF(MY_WME)); delete ce; @@ -622,13 +652,7 @@ Create_file event for file_id: %u\n",exv->file_id); if (fname) { - /* - Fix the path so it can be consumed by mysql client (requires Unix path). - */ - int stop= strlen(fname); - for (int i= 0; i < stop; i++) - if (fname[i] == '\\') - fname[i]= '/'; + convert_path_to_forward_slashes(fname); exlq->print(result_file, print_event_info, fname); my_free(fname, MYF(MY_WME)); } -- cgit v1.2.1