diff options
author | Brandon Nesterenko <brandon.nesterenko@mariadb.com> | 2021-10-06 07:42:03 -0600 |
---|---|---|
committer | Brandon Nesterenko <brandon.nesterenko@mariadb.com> | 2021-10-06 07:50:37 -0600 |
commit | 1ce35c327ed90fa67da53a3f9d470f195d879417 (patch) | |
tree | c12f28d58777418193632f646b9857eaeede167f /client | |
parent | d28b118d7b186391be8d091c00d9cf889c863f1a (diff) | |
download | mariadb-git-1ce35c327ed90fa67da53a3f9d470f195d879417.tar.gz |
MDEV-25444: mysql --binary-mode is not able to replay some mysqlbinlog outputsbb-10.2-MDEV-25444
Note: This patch backports commits 10cd281 and 1755ea4 from 10.3.
10cd281:
Problem:- Some binary data is inserted into the table using
Jconnector. When binlog dump of the data is applied using mysql
client it gives syntax error.
Reason:-
After investigating it turns out to be a issue of mysql client not
able to properly handle \\0 <0 in binary>. In all binary files
where mysql client fails to insert
these 2 bytes are common (0x5c00)
Solution:-
I have changed mysql.cc to include for the possibility that binary
string can have \\0 in it
1755ea4:
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')
-rw-r--r-- | client/mysql.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index 2eb44d46512..2baac7b92b8 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2335,7 +2335,14 @@ static bool add_line(String &buffer, char *line, ulong line_length, { // Found possbile one character command like \c - if (!(inchar = (uchar) *++pos)) + /* + 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 |