Skip to content

Commit 10cd281

Browse files
mariadb-SachinSetiyabnestere
authored andcommitted
MDEV-25444 mysql --binary-mode is not able to replay some mysqlbinlog outputs
Problem:- Some binary data is inserted into the table using Jconnector. When binlog dump of the data is applied using mysql cleint 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 commom (0x5c00) Solution:- I have changed mysql.cc to include for the possibility that binary string can have \\\0 in it
1 parent 1d57892 commit 10cd281

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

client/mysql.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,8 +2319,12 @@ static bool add_line(String &buffer, char *line, size_t line_length,
23192319
{
23202320
// Found possbile one character command like \c
23212321

2322-
if (!(inchar = (uchar) *++pos))
2323-
break; // readline adds one '\'
2322+
inchar = (uchar) *++pos;
2323+
// In Binary mode , when in_string is not null \0 should not be treated as
2324+
// end statement. This can happen when we are in middle of binary data which
2325+
// can contain \0 and its quoted with ' '.
2326+
if (!real_binary_mode && !*in_string && !inchar)
2327+
break; // readline adds one '\'
23242328
if (*in_string || inchar == 'N') // \N is short for NULL
23252329
{ // Don't allow commands in string
23262330
*out++='\\';
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CREATE TABLE `tb` (`id` int(11) NOT NULL AUTO_INCREMENT,`cb` longblob DEFAULT NULL,
2+
PRIMARY KEY (`id`)) ENGINE=myisam AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
3+
select count(*)=2 from tb;
4+
count(*)=2
5+
1
6+
drop table tb;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#
2+
# MDEV-25444 mysql --binary-mode is not able to replay some mysqlbinlog outputs
3+
#
4+
# After investigating it turns out to be a issue of mysql client not able to properly
5+
# handle \\\0 <0 in binary>.
6+
# In this test case we will be pipelining binary_zero_insert.bin into mysql client.
7+
# binary_zero_insert.bin contains insert stmt with \\\0
8+
9+
CREATE TABLE `tb` (`id` int(11) NOT NULL AUTO_INCREMENT,`cb` longblob DEFAULT NULL,
10+
PRIMARY KEY (`id`)) ENGINE=myisam AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
11+
12+
--exec $MYSQL --binary-mode test < $MYSQL_TEST_DIR/std_data/binary_zero_insert.bin
13+
select count(*)=2 from tb;
14+
15+
drop table tb;
87 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)