Sql wrong lexical analysis for string literals - escaped single quotes are misparsed

Description

The following sql is not parsed well when an escaped single quote is present in the end of sql parameter value.

--changeset eugen.maysyuk:01.01.000.0001
--comment create test table
CREATE TABLE `table1` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`text` mediumtext,
PRIMARY KEY (`ID`)
);

CREATE TABLE `table2` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`text` mediumtext,
PRIMARY KEY (`ID`)
);

--changeset eugen.maysyuk:01.01.000.0002
--comment issue with escaped quote
INSERT INTO `table1` VALUES (3,'TEXT \'');

INSERT INTO `table2` VALUES (4,'TEXT');

Same sql file works fine up till 3.4.2 (<= 3.4.2).

Attached is a sample project that reproduce the problem (GitHub).

Environment

Windows
Linux
macOS

Reporter

Eugen Maysyuk

Components

Affects versions

Priority

Critical
Configure