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.
This commit is contained in:
parent
495fd27c0e
commit
c579bce349
@ -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];
|
||||
|
Loading…
x
Reference in New Issue
Block a user