TiKV and TiFlash behave differently when performing type conversion
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
### 1. Minimal reproduce step (Required)
```sql
create table t1 (
c_k int unique ,
primary key(c_k) CLUSTERED);
alter table t1 set tiflash replica 1;
insert into t1 (c_k) values (-3), (-10), (-1776762042), (25);
SELECT /*+ read_from_storage(tiflash[t1]) */ c_k as c3, cast(c_k | c_k as char),cast(cast(c_k | c_k as char) as signed) FROM t1;
```
### 2. What did you expect to see? (Required)
```
mysql> SELECT /*+ read_from_storage(tikv[t1]) */ c_k as c3, cast(c_k | c_k as char),cast(cast(c_k | c_k as char) as signed) FROM t1;
+-------------+-------------------------+-----------------------------------------+
| c3 | cast(c_k | c_k as char) | cast(cast(c_k | c_k as char) as signed) |
+-------------+-------------------------+-----------------------------------------+
| -1776762042 | 18446744071932789574 | -1776762042 |
| -10 | 18446744073709551606 | -10 |
| -3 | 18446744073709551613 | -3 |
| 25 | 25 | 25 |
+-------------+-------------------------+-----------------------------------------+
4 rows in set, 3 warnings (0.01 sec)
mysql> show warnings;
+---------+------+-----------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+-----------------------------------------------------------------------------------+
| Warning | 8030 | Cast to signed converted positive out-of-range integer to its negative complement |
| Warning | 8030 | Cast to signed converted positive out-of-range integer to its negative complement |
| Warning | 8030 | Cast to signed converted positive out-of-range integer to its negative complement |
+---------+------+-----------------------------------------------------------------------------------+
3 rows in set (0.01 sec)
```
### 3. What did you see instead (Required)
```
mysql> SELECT /*+ read_from_storage(tiflash[t1]) */ c_k as c3, cast(c_k | c_k as char),cast(cast(c_k | c_k as char) as signed) FROM t1;
+-------------+-------------------------+-----------------------------------------+
| c3 | cast(c_k | c_k as char) | cast(cast(c_k | c_k as char) as signed) |
+-------------+-------------------------+-----------------------------------------+
| -1776762042 | 18446744071932789574 | 9223372036854775807 |
| -10 | 18446744073709551606 | 9223372036854775807 |
| -3 | 18446744073709551613 | 9223372036854775807 |
| 25 | 25 | 25 |
+-------------+-------------------------+-----------------------------------------+
4 rows in set (0.00 sec)
```
### 4. What is your TiDB version? (Required)
```
Release Version: v8.2.0-alpha-292-g7629a0d
Edition: Community
Git Commit Hash: 7629a0d68595c4d11c25fc059208f3efd838c2c1
Git Branch: HEAD
UTC Build Time: 2024-06-04 03:27:25
GoVersion: go1.21.10
Race Enabled: false
Check Table Before Drop: false
Store: tikv
```
topology:
distributed.yaml:
```
global:
user: "tidb"
ssh_port: 22
deploy_dir: "/tidb-deploy"
data_dir: "/tidb-data"
pd_servers:
- host: 10.0.2.31
tidb_servers:
- host: 10.0.2.21
tikv_servers:
- host: 10.0.2.11
- host: 10.0.2.12
- host: 10.0.2.13
monitoring_servers:
- host: 10.0.2.8
grafana_servers:
- host: 10.0.2.8
alertmanager_servers:
- host: 10.0.2.8
tiflash_servers:
- host: 10.0.2.32
```
### about us
We are the BASS team from the School of Cyber Science and Technology at Beihang University. Our main focus is on system software security, operating systems, and program analysis research, as well as the development of automated program testing frameworks for detecting software defects. Using our self-developed database vulnerability testing tool, we have identified the above-mentioned vulnerabilities in TiDB that may lead to database logic error.
Contributor guide
Assessment
This issue has not been assessed yet.