pingcap / pingcap/tidb

REGEXP fails with invalid pattern

Open
#48,360 7 comments 0 reactions 0 assignees View on GitHub
affects-7.1 affects-7.5 affects-8.1 affects-8.5 compatibility-mysql80 may-affects-5.3 may-affects-5.4 may-affects-6.1 may-affects-6.5 severity/major sig/execution type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

### 1. Minimal reproduce step (Required)

```sql
CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT, data VARCHAR(255));
SELECT data FROM t1 WHERE data REGEXP '[\[,]23[\],]' LIMIT 1;
```

### 2. What did you expect to see? (Required)

MySQL 8.2.0
```
sql> CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT, data VARCHAR(255));
Query OK, 0 rows affected (0.1066 sec)

sql> SELECT data FROM t1 WHERE data REGEXP '[\[,]23[\],]' LIMIT 1;
Empty set (0.0264 sec)
```

### 3. What did you see instead (Required)

```
sql> CREATE TABLE t1 (id INT PRIMARY KEY AUTO_INCREMENT, data VARCHAR(255));
Query OK, 0 rows affected (0.1961 sec)

sql> SELECT data FROM t1 WHERE data REGEXP '[\[,]23[\],]' LIMIT 1;
ERROR: 1105 (HY000): other error: Invalid regexp pattern: Syntax(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
regex parse error:
[[,]23[],]
^
error: unclosed character class
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
)
```

### 4. What is your TiDB version? (Required)

```
Release Version: v7.4.0
Edition: Community
Git Commit Hash: 38cb4f3312be9199a983c0ef282d2ea2e28a7824
Git Branch: heads/refs/tags/v7.4.0
UTC Build Time: 2023-10-10 14:18:50
GoVersion: go1.21.1
Race Enabled: false
Check Table Before Drop: false
Store: tikv
1 row in set (0.0011 sec)
```

Also reproduced with v7.1.1

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.