pingcap / pingcap/tidb

LIKE clause with custom ESCAPE character fails in INFORMATION_SCHEMA queries

Open
#63,170 1 comment 0 reactions 0 assignees View on GitHub
affects-5.4 affects-6.1 affects-6.5 affects-7.1 affects-7.5 affects-8.1 affects-8.5 affects-9.0 component/ddl contribution first-time-contributor severity/moderate type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)
1. Get the TiUP
```
~ curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
```
2. Launch mysql
```
~ mysql --comments --host 127.0.0.1 --port 4000 -u root
```
3. Use `test` db
```
mysql> use test;
```
4. Create `persons_1` and `persons_2` tables
```
mysql> CREATE TABLE persons_1 (PersonID int);
Query OK, 0 rows affected (0.06 sec)
mysql> CREATE TABLE persons_2 (PersonID int);
Query OK, 0 rows affected (0.03 sec)
```
5. Check the created tables
```
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| persons_1 |
| persons_2 |
+----------------+
2 rows in set (0.00 sec)
```
6. Query `INFORMATION_SCHEMA.TABLES` for tables whose name starts with `persons_` with custom escape char `!`
```
mysql> SELECT TABLE_NAME, TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME LIKE 'persons!_%' ESCAPE '!';
```

### 2. What did you expect to see? (Required)
```
+------------+------------+
| TABLE_NAME | TABLE_ROWS |
+------------+------------+
| persons_1 | 0 |
| persons_2 | 0 |
+------------+------------+
2 rows in set (0.01 sec)
```

### 3. What did you see instead (Required)
```
Empty set (0.00 sec)
```

### 4. What is your TiDB version? (Required)
```
mysql> SELECT tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.5.3
Edition: Community
Git Commit Hash: dc2548aac79a712265e831cff2a3a896bc0a5a38
Git Branch: HEAD
UTC Build Time: 2025-07-31 13:54:59
GoVersion: go1.23.6
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)
```

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.