[Compatibility] Support embedded quota in string literal (#5045)

```
mysql> select 'I''m a student';
+-----------------+
| 'I'm a student' |
+-----------------+
| I'm a student   |
+-----------------+

mysql> select "I""m a student";
+-----------------+
| 'I"m a student' |
+-----------------+
| I"m a student   |
+-----------------+

mysql> select 'I""m a student';
+------------------+
| 'I""m a student' |
+------------------+
| I""m a student   |
+------------------+

mysql> select "I''m a student";
+------------------+
| 'I''m a student' |
+------------------+
| I''m a student   |
+------------------+
```
This commit is contained in:
sduzh
2020-12-10 21:34:06 +08:00
committed by GitHub
parent bc063ebce2
commit e47fb502b2

View File

@ -506,8 +506,8 @@ IdentifierOrKwContents = [:digit:]*[:jletter:][:jletterdigit:]* | "&&" | "||"
IdentifierOrKw = \`{IdentifierOrKwContents}\` | {IdentifierOrKwContents}
IntegerLiteral = [:digit:][:digit:]*
QuotedIdentifier = \`(\`\`|[^\`])*\`
SingleQuoteStringLiteral = \'(\\.|[^\\\'])*\'
DoubleQuoteStringLiteral = \"(\\.|[^\\\"])*\"
SingleQuoteStringLiteral = \'(\\.|[^\\\']|\'\')*\'
DoubleQuoteStringLiteral = \"(\\.|[^\\\"]|\"\")*\"
FLit1 = [0-9]+ \. [0-9]*
FLit2 = \. [0-9]+
@ -595,12 +595,12 @@ EndOfLineComment = "--" !({HintContent}|{ContainsLineTerminator}) {LineTerminato
{SingleQuoteStringLiteral} {
return newToken(SqlParserSymbols.STRING_LITERAL,
escapeBackSlash(yytext().substring(1, yytext().length()-1)));
escapeBackSlash(yytext().substring(1, yytext().length()-1)).replaceAll("''", "'"));
}
{DoubleQuoteStringLiteral} {
return newToken(SqlParserSymbols.STRING_LITERAL,
escapeBackSlash(yytext().substring(1, yytext().length()-1)));
escapeBackSlash(yytext().substring(1, yytext().length()-1)).replaceAll("\"\"", "\""));
}
{CommentedHintBegin} {