| Bug #112729 | Two single quotes escaping inconsistency in index expression | ||
|---|---|---|---|
| Submitted: | 15 Oct 2023 11:20 | Modified: | 16 Oct 2023 6:12 |
| Reporter: | Nathee Jaywaree | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Server: Parser | Severity: | S3 (Non-critical) |
| Version: | 8.1.0 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | escape backslash, single quote | ||
[16 Oct 2023 6:12]
MySQL Verification Team
Hello Nathee Jaywaree, Thank you for the report and feedback. regards, Umesh

Description: Two single quotes are not being escaped correctly with NO_BACKSLASH_ESCAPES sql mode enabled in index expressions as shown below. It is unexpected that the same string is accepted in the SELECT statement, but results in an error when used in the CREATE INDEX statement. Using double quotes does not cause the problem. How to repeat: NO_BACKSLASH_ESCAPES mode not enabled: SELECT ''''; -- returns ' SELECT """"; -- returns " CREATE TABLE t0 (c0 INT); CREATE INDEX i0 ON t0 (('''')); -- OK CREATE INDEX i1 ON t0 (("""")); -- OK NO_BACKSLASH_ESCAPES mode enabled: SET sql_mode = "NO_BACKSLASH_ESCAPES"; SELECT ''''; -- returns ' SELECT """"; -- returns " CREATE TABLE t0 (c0 INT); CREATE INDEX i0 ON t0 (('''')); -- ERROR 1064 (42000): 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 ''\'')' at line 1 CREATE INDEX i1 ON t0 (("""")); -- OK