Description:
use mysqlbinlog to process binlog file and load to mysql server by mysql client.
But when we use mysql client assigned --default-character-set=binary, we got an error:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ';\x0A\x0A\x0ASET TIMESTAMP=1521886260' at line 1
mysql> DELIMITER aa;
mysql> select 1 aa
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)
mysql> delimiter ab;
mysql> select 1 ab;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)
How to repeat:
1. use 5.6/5.7 mysql client connect mysql server,assign --default-character-set=binary
2. execute sql:
DELIMITER /*!*/;
3. execute sql:
SET TIMESTAMP=1521894432/*!*/;
error happend:
ERROR 1064 (42000) at line 7: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ';\x0A\x0A\x0ASET TIMESTAMP=1521886260' at line 1
Suggested fix:
This error was caused by incorrect execute:DELIMITER /*!*/;
In correct situation, after execute this command,the DELIMITER should be set to:/*!*/;(with semicolon)
Actually, the DELIMITER had been set to /*!*/ (without semicolon)
The reason for this is caused by character_set, any case sensitive character_set had the same problem
mysql client function use is_delimiter_command to judge whether is a delimiter command ,this function use the client character(--default-chacter-set) to compare string.
But in another code logic(find_command),use fixed my_charset_latin1 to judge
To fix this bug,we only need to assgined a fixed charset my_charset_latin1,this modify only affect mysql client command DELIMITER.
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -1181,7 +1181,7 @@ inline bool is_delimiter_command(char *name, ulong len)
only name(first DELIMITER_NAME_LEN bytes) is checked.
*/
return (len >= DELIMITER_NAME_LEN &&
- !my_strnncoll(charset_info, (uchar*) name, DELIMITER_NAME_LEN,
+ !my_strnncoll(&my_charset_latin1, (uchar*) name, DELIMITER_NAME_LEN,
(uchar *) DELIMITER_NAME, DELIMITER_NAME_LEN));
}
Description: use mysqlbinlog to process binlog file and load to mysql server by mysql client. But when we use mysql client assigned --default-character-set=binary, we got an error:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ';\x0A\x0A\x0ASET TIMESTAMP=1521886260' at line 1 mysql> DELIMITER aa; mysql> select 1 aa +---+ | 1 | +---+ | 1 | +---+ 1 row in set (0.00 sec) mysql> delimiter ab; mysql> select 1 ab; +---+ | 1 | +---+ | 1 | +---+ 1 row in set (0.00 sec) How to repeat: 1. use 5.6/5.7 mysql client connect mysql server,assign --default-character-set=binary 2. execute sql: DELIMITER /*!*/; 3. execute sql: SET TIMESTAMP=1521894432/*!*/; error happend: ERROR 1064 (42000) at line 7: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ';\x0A\x0A\x0ASET TIMESTAMP=1521886260' at line 1 Suggested fix: This error was caused by incorrect execute:DELIMITER /*!*/; In correct situation, after execute this command,the DELIMITER should be set to:/*!*/;(with semicolon) Actually, the DELIMITER had been set to /*!*/ (without semicolon) The reason for this is caused by character_set, any case sensitive character_set had the same problem mysql client function use is_delimiter_command to judge whether is a delimiter command ,this function use the client character(--default-chacter-set) to compare string. But in another code logic(find_command),use fixed my_charset_latin1 to judge To fix this bug,we only need to assgined a fixed charset my_charset_latin1,this modify only affect mysql client command DELIMITER. --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1181,7 +1181,7 @@ inline bool is_delimiter_command(char *name, ulong len) only name(first DELIMITER_NAME_LEN bytes) is checked. */ return (len >= DELIMITER_NAME_LEN && - !my_strnncoll(charset_info, (uchar*) name, DELIMITER_NAME_LEN, + !my_strnncoll(&my_charset_latin1, (uchar*) name, DELIMITER_NAME_LEN, (uchar *) DELIMITER_NAME, DELIMITER_NAME_LEN)); }