diff options
author | Brandon Nesterenko <brandon.nesterenko@mariadb.com> | 2021-09-30 15:03:44 -0600 |
---|---|---|
committer | Brandon Nesterenko <brandon.nesterenko@mariadb.com> | 2021-10-05 10:54:57 -0600 |
commit | 1755ea4b4903489e1e53375bc1f26fa5f42a7a12 (patch) | |
tree | f0a7fa2040514dd39db2a95fdc48b937d9fac9eb /client/mysql.cc | |
parent | 10cd281820cdcbef2fd9bc68c97325659f84de4a (diff) | |
download | mariadb-git-bb-10.3-25444.tar.gz |
MDEV-25444: mysql --binary-mode is not able to replay some mysqlbinlog outputsbb-10.3-25444
Changes on top of Sachin’s patch. Specifically:
1) Refined the parsing break condition to only change the parser’s
behavior for parsing strings in binary mode (behavior of \0 outside
of strings is unchanged).
2) Prefixed binary_zero_insert.test with ‘mysql_’ to more clearly
associate the purpose of the test.
3) As the input of the test contains binary zeros (0x5c00),
different text editors can visualize this sequence differently, and
Github would not display it at all. Therefore, the input itself was
consolidated into the test and created out of hex sequences to make
it easier to understand what is happening.
4) Extended test to validate that the rows which correspond to the
INSERTS with 0x5c00 have the correct binary zero data.
Reviewed By:
===========
Andrei Elkin <andrei.elkin@mariadb.com>
Diffstat (limited to 'client/mysql.cc')
-rw-r--r-- | client/mysql.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index 8530c105820..21060013c75 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2319,11 +2319,14 @@ static bool add_line(String &buffer, char *line, size_t line_length, { // Found possbile one character command like \c - inchar = (uchar) *++pos; - // In Binary mode , when in_string is not null \0 should not be treated as - // end statement. This can happen when we are in middle of binary data which - // can contain \0 and its quoted with ' '. - if (!real_binary_mode && !*in_string && !inchar) + /* + The null-terminating character (ASCII '\0') marks the end of user + input. Then, by default, upon encountering a '\0' while parsing, it + should stop. However, some data naturally contains binary zeros + (e.g., zipped files). Real_binary_mode signals the parser to expect + '\0' within the data and not to end parsing if found. + */ + if (!(inchar = (uchar) *++pos) && (!real_binary_mode || !*in_string)) break; // readline adds one '\' if (*in_string || inchar == 'N') // \N is short for NULL { // Don't allow commands in string |