Skip to content

Unexpected error "Cannot convert string '\x15t\x03\x10\x93' from binary to utf8mb4" #65386

@DerZc

Description

@DerZc

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: 71caddf\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

Metadata

Metadata

Assignees

No one assigned

    Labels

    contributionThis PR is from a community contributor.sig/sql-infraSIG: SQL Infratype/bugThe issue is confirmed as a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions