Inconsistent results of DATA_FORMAT when used in normal SELECT and prepared SELECT
- 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,
In the following test case, there are two equivalent SELECT statements, one is a normal SELECT, and the other is a prepared SELECT, however, the normal SELECT returns one row, but the prepared SELECT returns empty result.
```
CREATE TABLE t29(c0 DECIMAL );
REPLACE INTO t29(c0) VALUES (1);
SELECT t29.c0 FROM t29 WHERE DATE_FORMAT(422123206, (BINARY (-81775))); -- 1
SET @c=-81775;
PREPARE prepare_query FROM 'SELECT t29.c0 FROM t29 WHERE DATE_FORMAT(422123206, (BINARY (?)))';
EXECUTE prepare_query USING @c; -- empty result
```
### 2. What did you expect to see? (Required)
These two queries have the same results.
### 3. What did you see instead (Required)
These two queries have different results.
### 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.