Commit cb0afbd1 authored by Neeraj Bisht's avatar Neeraj Bisht

Bug#18207212 : FILE NAME IS NOT ESCAPED IN BINLOG FOR LOAD DATA INFILE STATEMENT

Problem:
Load_log_event::print_query() function does not put escape character in file name 
for "LOAD DATA INFILE" statement.

Analysis:
When we have "'" in our file name for "LOAD DATA INFILE" statement,
Load_log_event::print_query() function does not put escape character 
in our file name.

This one result that when we show binary-log, we get file name without 
escape character.

Solution:
To put escape character when we have "'" in file name, for this instead of using 
simple memcpy() to put file-name, we will use pretty_print_str().
parent 4c4def90
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. /* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -408,6 +408,13 @@ process_flags: ...@@ -408,6 +408,13 @@ process_flags:
if (my_b_write(info, (uchar*) par, length2)) if (my_b_write(info, (uchar*) par, length2))
goto err; goto err;
} }
else if (*fmt == 'c') /* char type parameter */
{
char par[2];
par[0] = va_arg(args, int);
if (my_b_write(info, (uchar*) par, 1))
goto err;
}
else if (*fmt == 'b') /* Sized buffer parameter, only precision makes sense */ else if (*fmt == 'b') /* Sized buffer parameter, only precision makes sense */
{ {
char *par = va_arg(args, char *); char *par = va_arg(args, char *);
......
...@@ -4384,7 +4384,7 @@ uint Load_log_event::get_query_buffer_length() ...@@ -4384,7 +4384,7 @@ uint Load_log_event::get_query_buffer_length()
return return
//the DB name may double if we escape the quote character //the DB name may double if we escape the quote character
5 + 2*db_len + 3 + 5 + 2*db_len + 3 +
18 + fname_len + 2 + // "LOAD DATA INFILE 'file''" 18 + fname_len*4 + 2 + // "LOAD DATA INFILE 'file''"
11 + // "CONCURRENT " 11 + // "CONCURRENT "
7 + // LOCAL 7 + // LOCAL
9 + // " REPLACE or IGNORE " 9 + // " REPLACE or IGNORE "
...@@ -4430,9 +4430,9 @@ void Load_log_event::print_query(bool need_db, const char *cs, char *buf, ...@@ -4430,9 +4430,9 @@ void Load_log_event::print_query(bool need_db, const char *cs, char *buf,
if (check_fname_outside_temp_buf()) if (check_fname_outside_temp_buf())
pos= strmov(pos, "LOCAL "); pos= strmov(pos, "LOCAL ");
pos= strmov(pos, "INFILE '"); pos= strmov(pos, "INFILE ");
memcpy(pos, fname, fname_len); pos= pretty_print_str(pos, fname, fname_len);
pos= strmov(pos+fname_len, "' "); pos= strmov(pos, " ");
if (sql_ex.opt_flags & REPLACE_FLAG) if (sql_ex.opt_flags & REPLACE_FLAG)
pos= strmov(pos, "REPLACE "); pos= strmov(pos, "REPLACE ");
...@@ -7339,9 +7339,9 @@ void Execute_load_query_log_event::print(FILE* file, ...@@ -7339,9 +7339,9 @@ void Execute_load_query_log_event::print(FILE* file,
if (local_fname) if (local_fname)
{ {
my_b_write(&cache, (uchar*) query, fn_pos_start); my_b_write(&cache, (uchar*) query, fn_pos_start);
my_b_printf(&cache, " LOCAL INFILE \'"); my_b_printf(&cache, " LOCAL INFILE ");
my_b_printf(&cache, "%s", local_fname); pretty_print_str(&cache, local_fname, strlen(local_fname));
my_b_printf(&cache, "\'");
if (dup_handling == LOAD_DUP_REPLACE) if (dup_handling == LOAD_DUP_REPLACE)
my_b_printf(&cache, " REPLACE"); my_b_printf(&cache, " REPLACE");
my_b_printf(&cache, " INTO"); my_b_printf(&cache, " INTO");
......
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