-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Closed
Copy link
Labels
severity/moderatesig/plannerSIG: PlannerSIG: Plannertype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.
Description
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
The following query contains two equivalent queries, one is a normal SELECT query, and another one is a prepared statement. However, they have different results. The normal SELECT query returns 1 row, but the prepared statement returns an empty result.
CREATE TABLE t0(c0 DECIMAL);
INSERT INTO t0 VALUES (0);
SELECT * FROM t0 WHERE CAST((CASE t0.c0 WHEN t0.c0 THEN CAST(t0.c0 AS TIME) ELSE NULL END ) AS DATE);
SET @b = NULL;
PREPARE prepare_query FROM 'SELECT * FROM t0 WHERE CAST((CASE t0.c0 WHEN t0.c0 THEN CAST(t0.c0 AS TIME) ELSE ? END ) AS DATE)';
EXECUTE prepare_query USING @b;
2. What did you expect to see? (Required)
These two queries have the same result.
3. What did you see instead (Required)
These two queries have different results.
4. What is your TiDB version? (Required)
tidb_version()
Release Version: v9.0.0-beta.2.pre-149-g96f5396\nEdition: Community\nGit Commit Hash: 96f5396\nGit Branch: HEAD\nUTC Build Time: 2025-07-21 20:48:44\nGoVersion: go1.23.11\nRace Enabled: false\nCheck Table Before Drop: false\nStore: tikv\nKernel Type: Classic
Metadata
Metadata
Assignees
Labels
severity/moderatesig/plannerSIG: PlannerSIG: Plannertype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.