Hi Sven
This patch fixes BUG#33975 too, please see the comments below.
On 2008-02-06 Wed 19:13 +0100,Sven Sandberg wrote:
> Below is the list of changes that have just been committed into a local
> 5.1 repository of sven. When sven does a push these changes
> will be propagated to the main repository and, within 24 hours after the
> push, to the public repository.
> For information on how to access the public repository
> see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
>
> ChangeSet@stripped, 2008-02-06 19:13:51+01:00, sven@riska.(none) +1 -0
> 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 expect forward slashes.
> Fix: Replace '\\' by '/' in filenames.
>
> client/mysqlbinlog.cc@stripped, 2008-02-06 19:13:50+01:00, sven@riska.(none) +22 -7
> Replace windows path separator backslash by unix path separator forward
> slash in filenames also for Create_file_log_event.
>
> diff -Nrup a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
> --- a/client/mysqlbinlog.cc 2008-02-01 20:28:20 +01:00
> +++ b/client/mysqlbinlog.cc 2008-02-06 19:13:50 +01:00
> @@ -483,6 +483,22 @@ static bool check_database(const char *l
> }
>
>
> +/**
> + Replace windows-style backslashes by forward slashes so it can be
> + consumed by the mysql client, which requires Unix path.
> +
> + @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 int
> write_event_header_and_base64(Log_event *ev, FILE *result_file,
> @@ -627,6 +643,11 @@ int process_event(PRINT_EVENT_INFO *prin
> */
> 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);
I would prefer change the ce->print method instead of modify the
ce->fname attribute.
This is not a problem now because we don't use ce->fname any more after
calling ce->print, but this might change in the future. And if we call
ce->print in some other places in the future, we have to call
convert_path_to_forward_slashes before that too. So IMHO, I think modify
ce->print method might be better.
> my_free((char*)ce->fname,MYF(MY_WME));
> delete ce;
> @@ -675,13 +696,7 @@ Create_file event for file_id: %u\n",exv
>
> 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);
See previous comment.
> my_free(fname, MYF(MY_WME));
> }