pingcap / pingcap/tidb

Wrong result in TiKV of year comparsion

Open
#59,001 0 comments 0 reactions 0 assignees View on GitHub
affects-8.5 impact/wrong-result may-affects-6.5 may-affects-7.1 may-affects-7.5 may-affects-8.1 severity/major 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)

```sql
DROP TABLE IF EXISTS t0;
CREATE TABLE t0(c0 YEAR NOT NULL );
CREATE INDEX i0 ON t0(c0);
REPLACE INTO t0(c0) VALUES ('1935'), ('1982');
ALTER TABLE t0 SET TIFLASH REPLICA 1;
SELECT /*+ READ_FROM_STORAGE(tikv[t0]) */ t0.c0 FROM t0 WHERE 0.025 <= t0.c0;
SELECT /*+ READ_FROM_STORAGE(tiflash[t0]) */ t0.c0 FROM t0 WHERE 0.025 <= t0.c0;
```

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

see the following case: TiKV and Tiflash return different result

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

```sql
mysql> SELECT /*+ READ_FROM_STORAGE(tiflash[t0]) */ t0.c0 FROM t0 WHERE 0.025 <= t0.c0;
+------+
| c0 |
+------+
| 1935 |
| 1982 |
+------+
2 rows in set (0.04 sec)

mysql> SELECT /*+ READ_FROM_STORAGE(tikv[t0]) */ t0.c0 FROM t0 WHERE 0.025 <= t0.c0;
Empty set (0.04 sec)
```

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

8.5.0

Contributor guide

Open the contributing guide

Research direction

Start by running the provided SQL reproduction on TiKV and TiFlash with TiDB 8.5.0, then trace how the YEAR comparison is evaluated in each storage path. Done means both storage hints return consistent, correct results for the reproduction case, with regression coverage for the discrepancy.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.