summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/mysql.cc8
-rw-r--r--mysql-test/main/binary_zero_insert.result6
-rw-r--r--mysql-test/main/binary_zero_insert.test15
-rw-r--r--mysql-test/std_data/binary_zero_insert.binbin0 -> 87 bytes
4 files changed, 27 insertions, 2 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 2a7c4eaf3e5..8530c105820 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -2319,8 +2319,12 @@ static bool add_line(String &buffer, char *line, size_t line_length,
{
// Found possbile one character command like \c
- if (!(inchar = (uchar) *++pos))
- break; // readline adds one '\'
+ 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)
+ break; // readline adds one '\'
if (*in_string || inchar == 'N') // \N is short for NULL
{ // Don't allow commands in string
*out++='\\';
diff --git a/mysql-test/main/binary_zero_insert.result b/mysql-test/main/binary_zero_insert.result
new file mode 100644
index 00000000000..c46dc74f019
--- /dev/null
+++ b/mysql-test/main/binary_zero_insert.result
@@ -0,0 +1,6 @@
+CREATE TABLE `tb` (`id` int(11) NOT NULL AUTO_INCREMENT,`cb` longblob DEFAULT NULL,
+PRIMARY KEY (`id`)) ENGINE=myisam AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
+select count(*)=2 from tb;
+count(*)=2
+1
+drop table tb;
diff --git a/mysql-test/main/binary_zero_insert.test b/mysql-test/main/binary_zero_insert.test
new file mode 100644
index 00000000000..a8769199859
--- /dev/null
+++ b/mysql-test/main/binary_zero_insert.test
@@ -0,0 +1,15 @@
+#
+# MDEV-25444 mysql --binary-mode is not able to replay some mysqlbinlog outputs
+#
+# After investigating it turns out to be a issue of mysql client not able to properly
+# handle \\\0 <0 in binary>.
+# In this test case we will be pipelining binary_zero_insert.bin into mysql client.
+# binary_zero_insert.bin contains insert stmt with \\\0
+
+CREATE TABLE `tb` (`id` int(11) NOT NULL AUTO_INCREMENT,`cb` longblob DEFAULT NULL,
+PRIMARY KEY (`id`)) ENGINE=myisam AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
+
+--exec $MYSQL --binary-mode test < $MYSQL_TEST_DIR/std_data/binary_zero_insert.bin
+select count(*)=2 from tb;
+
+drop table tb;
diff --git a/mysql-test/std_data/binary_zero_insert.bin b/mysql-test/std_data/binary_zero_insert.bin
new file mode 100644
index 00000000000..8a91ae5d3e1
--- /dev/null
+++ b/mysql-test/std_data/binary_zero_insert.bin
Binary files differ