Skip to content

Commit 7b6ff85

Browse files
author
Alfranio Correia
committed
BUG#36391: "mysqlbinlog creates invalid charset statements"
The fix for BUG#20103 "Escaping with backslash does not work as expected" was implemented too greedy though in that it not only changes the behavior of backslashes within strings but in general, so disabling command shortcuts like \G or \C (which in turn leads to Bug #36391: "mysqlbinlog creates invalid charset statements"). The fix allows the escaping with backslash to take place only inside a string, thus enabling the execution of command shortcuts and presevering the fix for BUG#20103.
1 parent 7b92f9c commit 7b6ff85

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

client/mysql.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -2044,7 +2044,8 @@ static bool add_line(String &buffer,char *line,char *in_string,
20442044
}
20452045
#endif
20462046
if (!*ml_comment && inchar == '\\' &&
2047-
!(mysql.server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES))
2047+
!(*in_string &&
2048+
(mysql.server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES)))
20482049
{
20492050
// Found possbile one character command like \c
20502051

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
stop slave;
2+
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
3+
reset master;
4+
reset slave;
5+
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
6+
start slave;
7+
drop table if exists t1;
8+
Warnings:
9+
Note 1051 Unknown table 't1'
10+
create table t1(id int);
11+
show tables;
12+
Tables_in_test
13+
t1
14+
show master status;
15+
File Position Binlog_Do_DB Binlog_Ignore_DB
16+
master-bin.000001 278
17+
flush logs;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--sql_mode=NO_BACKSLASH_ESCAPES
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#
2+
# BUG#36391 and BUG#38731
3+
#
4+
# The fix for BUG#20103 "Escaping with backslash does not work as expected"
5+
# was implemented too greedy though in that it not only changes the behavior
6+
# of backslashes within strings but in general, so disabling command shortcuts
7+
# like \G or \C (which in turn leads to BUG#36391: "mysqlbinlog creates invalid charset statements".
8+
#
9+
# The test executes simple commands that are stored in the binary log and
10+
# re-execute them through the mysql client which should have to process
11+
# some command shortcuts. The backslashes within strings is disabled in the file
12+
# rpl_bug36391-master.opt by the option --sql_mode=NO_BACKSLASH_ESCAPES.
13+
#
14+
#
15+
16+
--source include/master-slave.inc
17+
18+
drop table if exists t1;
19+
20+
create table t1(id int);
21+
22+
show tables;
23+
24+
show master status;
25+
26+
flush logs;
27+
28+
--exec $MYSQL_BINLOG $MYSQL_TEST_DIR/var/log/master-bin.000001 | $MYSQL test

0 commit comments

Comments
 (0)