Bug #104674 MySQLLexer.g4 `BACK_TICK_QUOTED_ID `lexical rule definition bug
Submitted: 20 Aug 2021 9:05 Modified: 20 Aug 2021 9:23
Reporter: hao li Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:8.0, 8.0.26 OS:Any
Assigned to: CPU Architecture:Any

[20 Aug 2021 9:05] hao li
Description:
0.
Because of the needs of a certain business at work, I referred to your code.

1.
There is such a table in the database。
CREATE TABLE `test` ( 
	`id` INT ( 11 ) NOT NULL, 
	`x``x``x` VARCHAR ( 255 ), 
	PRIMARY KEY ( `id` ) USING BTREE 
);

2.
I want to add data by clicking the `insert new row` button, and the tool generates such a statement for me。

INSERT INTO `look`.`test` (`id`, `x`x`x`) VALUES ('2', '3');

3. 
I then clicked the `apply` button, and the tool reported an error.

Operation failed: There was an error while applying the SQL script to the database.
Executing:
INSERT INTO `look`.`test` (`id`, `x`x`x`) VALUES ('2', '3');

ERROR 1064: 1064: 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 'x`x`) VALUES ('2', '3')' at line 1
SQL Statement:
INSERT INTO `look`.`test` (`id`, `x`x`x`) VALUES ('2', '3')

How to repeat:
Create the table in the description, try to add data to it, it is easy to find the error.

Suggested fix:
In the following file, there is such a piece of code:

mysql-workbench/library/parsers/grammars/MySQLLexer.g4

fragment BACK_TICK:    '`';
fragment SINGLE_QUOTE: '\'';
fragment DOUBLE_QUOTE: '"';

BACK_TICK_QUOTED_ID: BACK_TICK (({!isSqlModeActive(NoBackslashEscapes)}? '\\')? .)*? BACK_TICK;

The key to the problem is that this code does not adapt to ``
[20 Aug 2021 9:23] MySQL Verification Team
Hello hao li,

Thank you for the report and test case.

regards,
Umesh