Bug #113015 REGEXP curly brackets without escape character works on 5.7 but not in 8.0
Submitted: 9 Nov 2023 3:25 Modified: 9 Nov 2023 5:35
Reporter: Aristotle Po Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:8.0.35 OS:Any
Assigned to: CPU Architecture:Any
Tags: REGEXP

[9 Nov 2023 3:25] Aristotle Po
Description:
REGEXP curly brackets without escape character  works on 5.7 but not in 8.0

How to repeat:
#######################################################
# 5.7
#######################################################
mysql [localhost:5744] {msandbox} (db1) > SELECT @@sql_mode, @@version, @@version_comment;
+--------------------------------------------+------------+------------------------------+
| @@sql_mode                                 | @@version  | @@version_comment            |
+--------------------------------------------+------------+------------------------------+
| STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION | 5.7.44-log | MySQL Community Server (GPL) |
+--------------------------------------------+------------+------------------------------+
1 row in set (0.00 sec)

mysql [localhost:5744] {msandbox} (db1) > SELECT 'test{' REGEXP '{|}';
+----------------------+
| 'test{' REGEXP '{|}' |
+----------------------+
|                    1 |
+----------------------+
1 row in set (0.00 sec)

#######################################################
# 8.0
#######################################################
mysql [localhost:8035] {msandbox} ((none)) > SELECT @@sql_mode, @@version, @@version_comment;
+--------------------------------------------+-----------+------------------------------+
| @@sql_mode                                 | @@version | @@version_comment            |
+--------------------------------------------+-----------+------------------------------+
| STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION | 8.0.35    | MySQL Community Server - GPL |
+--------------------------------------------+-----------+------------------------------+
1 row in set (0.00 sec)

mysql [localhost:8035] {msandbox} ((none)) > SELECT 'test{' REGEXP '{|}';
ERROR 3688 (HY000): Syntax error in regular expression on line 1, character 1.

#################################
# Workaround: Add escape character
#################################

mysql [localhost:8035] {msandbox} ((none)) > SELECT 'test{' REGEXP '\\{|\\}';
+--------------------------+
| 'test{' REGEXP '\\{|\\}' |
+--------------------------+
|                        1 |
+--------------------------+
1 row in set (0.00 sec)

Suggested fix:
Make it behave like 5.7
[9 Nov 2023 5:35] MySQL Verification Team
Hello Aristotle Po,

Thank you for the report and feedback.
Verified as described.

regards,
Umesh
[14 Nov 2023 7:35] Tor Didriksen
Posted by developer:
 
this page
https://dev.mysql.com/doc/refman/8.0/en/regexp.html#regexp-compatibility

mentions ')' and '['

it should also say something about '{' and '}'

mysql> SELECT 'test{' REGEXP '{|}';
ERROR 3688 (HY000): Syntax error in regular expression on line 1, character 1.
mysql> SELECT 'test{' REGEXP '\{|}';
ERROR 3688 (HY000): Syntax error in regular expression on line 1, character 4.
mysql> SELECT 'test{' REGEXP '\{|\}';
+--------------------------+
| 'test{' REGEXP '\{|\}' |
+--------------------------+
|                        1 |
+--------------------------+
1 row in set (0,00 sec)

ICU regexps are documented here: https://unicode-org.github.io/icu/userguide/strings/regexp.html