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:
None 
Category:MySQL Server: Parser Severity:S3 (Non-critical)
Version:8.1.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: escape backslash, single quote

[15 Oct 2023 11:20] Nathee Jaywaree
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
[16 Oct 2023 6:12] MySQL Verification Team
Hello Nathee Jaywaree,

Thank you for the report and feedback.

regards,
Umesh

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.037 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.