pingcap / pingcap/tidb

Incorrect result for DATE() with incorrect parameter type return null

Open
#64,388 0 comments 0 reactions 0 assignees View on GitHub
contribution sig/execution 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)

CREATE TABLE t233 (c1 TEXT, c2 TEXT);
INSERT t233 () VALUES ('3','T');
INSERT t233 () VALUES ('l','M');
SELECT * FROM t233 WHERE ((DATE((FLOOR(t233.c2))) != SOME (SELECT t233.c1 FROM t233)));
-- 2 rows
SELECT DATE((FLOOR(t233.c2))) FROM t233;
-- 2 rows of null

### 2. What did you expect to see? (Required)
The SELECT * query should return an empty set.
### 3. What did you see instead (Required)
mysql> SELECT * FROM t233 WHERE ((DATE((FLOOR(t233.c2))) != SOME (SELECT t233.c1 FROM t233)));
+------+------+
| c1 | c2 |
+------+------+
| 3 | T |
| l | M |
+------+------+
2 rows in set, 2 warnings (0.01 sec)
### 4. What is your TiDB version? (Required)

Release Version: v8.5.0-20251010-ec6b882
Edition: Community
Git Commit Hash: https://github.com/pingcap/tidb/commit/ec6b882d188f77c199907ba26843a872b8c5fd6d
Git Branch: heads/refs/tags/v8.5.0-20251010-ec6b882
UTC Build Time: 2025-10-10 10:21:51
GoVersion: go1.23.3
Race Enabled: false
Check Table Before Drop: false
Store: unistore

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.