pingcap / pingcap/tidb

planner: TIME column comparisons with temporal values use incompatible coercion semantics

Open
#70,751 2 comments 0 reactions 0 assignees View on GitHub
contribution may-affects-25.10 may-affects-26.3 may-affects-7.5 may-affects-8.1 may-affects-8.5 severity/critical sig/planner type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Comparing a `TIME` column with a `DATETIME` value may return a result inconsistent with MySQL because the date part of the `DATETIME` value affects the comparison.

### 1. Minimal reproduce step (Required)

```sql
CREATE TABLE t (
id INT PRIMARY KEY,
trx_time TIME
);

INSERT INTO t VALUES (1, '19:10:06');

SELECT id
FROM t
WHERE trx_time = CAST('1000-01-01 19:10:06' AS DATETIME);
```

### 2. What did you expect to see? (Required)

The query returns the row, consistent with MySQL:

```text
+----+
| id |
+----+
| 1 |
+----+
```

### 3. What did you see instead (Required)

The query returns an empty result.

### 4. What is your TiDB version? (Required)

```sql
mysql> SELECT tidb_version();
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v9.0.0-beta.2.pre-2156-ga80e3356c4
Edition: Community
Git Commit Hash: a80e3356c4befd6c4f316586b0f8e1bd5d24eb1f
Git Branch: master
UTC Build Time: 2026-08-31 05:56:58
GoVersion: go1.25.12
Race Enabled: false
Check Table Before Drop: false
Store: tikv
Kernel Type: Classic |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.001 sec)
```

Contributor guide

Open the contributing guide

Research direction

The issue names no files or tests. Start by running the provided CREATE TABLE, INSERT, and SELECT reproduction in TiDB, then compare the TIME-versus-DATETIME coercion path with MySQL behavior. Done means the query returns the inserted row, matching the expected result.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.