TiFlash cast blob as signed function's behavior is different with tidb for overflow cases
- 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)
prepare data
```sql
drop table if exists t0;
CREATE TABLE t0(c0 BLOB(123));
INSERT INTO t0(c0) VALUES ('1'),('2'),('3');
ALTER TABLE t0 SET TIFLASH REPLICA 1;
```
execute query
```sql
SELECT /*+ read_from_storage(tikv[t0]) */
*
FROM t0
WHERE
('4Y') & (
(CASE
true
WHEN ((t0.c0) >> (t0.c0)) THEN t0.c0
ELSE (~ (4.1))
END)
);
SELECT /*+ read_from_storage(tiflash[t0]) */
*
FROM t0
WHERE
('4Y') & (
(CASE
true
WHEN ((t0.c0) >> (t0.c0)) THEN t0.c0
ELSE (~ (4.1))
END)
);
```
### 2. What did you expect to see? (Required)
The results of the two queries are equal.
### 3. What did you see instead (Required)
Query1: empty
Query2:

### 4. What is your TiDB version? (Required)
Release Version: v8.4.0
Edition: Community
Git Commit Hash: 1a9f0fa25580907d3266dc3edf000ba24379a600
Git Branch: HEAD
UTC Build Time: 2024-11-07 15:18:43
GoVersion: go1.23.2
Race Enabled: false
Check Table Before Drop: false
Store: tikv
### 5. Note
Maybe duplication with https://github.com/pingcap/tidb/issues/57739.
Contributor guide
Research direction
Start by running the provided SQL setup and comparing the TiKV and TiFlash queries for the overflow case. Trace the cast-as-signed behavior involved in the query and verify that both storage paths produce equal results; the issue mentions no source file or test to begin from.
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