Repository navigation
Lex MySQL backslash escapes consistently in string literals - #2790
Merged
manticore-projects merged 1 commit intoOct 13, 2026
Merged
manticore-projects merged 1 commit into
manticore-projects merged 1 commit into
Conversation
With backslash escapes enabled, as in the MySQL and MariaDB presets, the lexer recognized only a few escapes and no doubled quote in the same literal. 'it\'s ''x''' silently split into a string and an alias, 'a\0b\'c', '\Z\'' and 'a''b\'c' failed, and the double-quoted "it\"s" ended at the escaped quote. Let both quote styles read any backslash escape and doubled quotes, then trim the token to the closing quote of the rules in effect. A backslash only escapes with backslash escapes enabled or in PostgreSQL E'' strings, so standard strings, LIKE ... ESCAPE '\' and quoted identifiers such as "col\" are unchanged. Signed-off-by: minleejae <mmj9808@gmail.com>
This was referenced Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Lex string literals with backslash escapes the way MySQL reads them. This applies with
Dialect.MYSQL,Dialect.MARIADBorwithBackslashEscapeCharacter(true). Today:SELECT 'it\'s ''x''' FROM tsilently splits into the string'it\'s 'and an alias'x'''.'a\0b\'c','\Z\'','a''b\'c'and'x\%\'y'fail with a lexical error."it\"s"fails as well.MySQL 8.4, MySQL 8.0 and MariaDB 11.4 read each of these as a single string.
Current design (As-is)
\n \t \b \r \f \\ \" \'and no doubled quote;\'/\''heuristics.Target design (To-be)
E''string.LIKE ... ESCAPE '\', Oracleq'...'literals, and quoted identifiers such as"col\".Validation
E''and standard strings;spotlessApply check: 10,096 tests, 10,071 passed, 25 skipped, zero failures/errors. The grammar choice conflict check passes. The full suite also passes unchanged against the reworked tokens."a\""b", which MySQL rejects, is rejected by the parser too.Integration validation
Applied #2788, #2789, #2790, #2791 and #2792 together on
master(166f0a27):spotlessApply check: 10,150 tests, 10,125 passed, 25 skipped, zero failures/errors.