summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2013-03-25 16:45:24 +0200
committerMichael Widenius <monty@askmonty.org>2013-03-25 16:45:24 +0200
commitc579bce3497bdf700b19bfe50a75e641330646d3 (patch)
treeff9b60b1a7f905cae696c786f37f9de0a47c0bfc
parent495fd27c0e3781013904666f302a3d3e4f011e50 (diff)
downloadmariadb-git-c579bce3497bdf700b19bfe50a75e641330646d3.tar.gz
Patch by Ian Good for MDEV-4319: mysqlbinlog output ambiguous escaping
The output of mysqlbinlog (with "-v --base64-output=DECODE-ROWS" flags) can not always be read or parsed correctly when string columns contain single-quotes or backslash characters. The fix for this bug is to escape single-quote and backslash characters on output, so that the result is both more readable and more easily parse-able. Note that this is just for comments, so it doesn't affect the replication. sql/log_event.cc: Escape \ and ' properly for mysqlbin user comments.
-rw-r--r--sql/log_event.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 44ff00f9b25..331b86ca29f 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -1804,6 +1804,7 @@ void Log_event::print_header(IO_CACHE* file,
/**
Prints a quoted string to io cache.
Control characters are displayed as hex sequence, e.g. \x00
+ Single-quote and backslash characters are escaped with a \
@param[in] file IO cache
@param[in] prt Pointer to string
@@ -1819,6 +1820,10 @@ my_b_write_quoted(IO_CACHE *file, const uchar *ptr, uint length)
{
if (*s > 0x1F)
my_b_write(file, s, 1);
+ else if (*s == '\'')
+ my_b_write(file, "\\'", 2);
+ else if (*s == '\\')
+ my_b_write(file, "\\\\", 2);
else
{
uchar hex[10];