Unexpected error "Cannot convert string '\x15t\x03\x10\x93' from binary to utf8mb4"
- 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)
Hi,
The following test case includes two type casts, one cast TEXT to BINARY, and the second cast the BINARY to CHAR. These two casts can be executed normally when executed individually, but an error will be triggered when they are placed in SUBSTRING_INDEX:
```
CREATE TABLE t0(c0 TEXT(458) );
INSERT INTO t0 VALUES ('-1574031093');
SELECT SUBSTRING_INDEX("a", UNHEX(CAST((- (CAST(t0.c0 AS BINARY))) AS CHAR)), 1) FROM t0; -- Cannot convert string '\x15t\x03\x10\x93' from binary to utf8mb4
SELECT UNHEX(CAST((- (CAST(t0.c0 AS BINARY))) AS CHAR)) FROM t0; -- t
SELECT SUBSTRING_INDEX("a", true, 1) FROM t0; -- -1574031093
```
### 2. What did you expect to see? (Required)
No error.
### 3. What did you see instead (Required)
Cannot convert string '\x15t\x03\x10\x93' from binary to utf8mb4
### 4. What is your TiDB version? (Required)
Release Version: v9.0.0-beta.2.pre-551-g71caddf56d\nEdition: Community\nGit Commit Hash: 71caddf56d9c1887650568101590417558149e3f\nGit Branch: master\nUTC Build Time: 2025-10-11 06:46:47\nGoVersion: go1.23.12\nRace Enabled: false\nCheck Table Before Drop: false\nStore: unistore\nKernel Type: Classic
Contributor guide
Assessment
This issue has not been assessed yet.