TiKV and TiFlash behave differently when using `right` function with negative number and 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 (c1 text, c2 int);
alter table t1 set tiflash replica 1;
insert into t1 (c1,c2) values ('k5tis', -65), ('x', 1), ('jp2hmweyyb', 1);
select /*+ read_from_storage(tiflash[t1]) */ right(c1 , cast(c2 as unsigned)) from t1;
```
### 2. What did you expect to see? (Required)
```
mysql> select /*+ read_from_storage(tikv[t1]) */ right(c1 , cast(c2 as unsigned)) from t1;
+----------------------------------+
| right(c1 , cast(c2 as unsigned)) |
+----------------------------------+
| |
| x |
| b |
+----------------------------------+
3 rows in set (0.00 sec)
mysql> select right('abcde', cast(-65 as unsigned));
+---------------------------------------+
| right('abcde', cast(-65 as unsigned)) |
+---------------------------------------+
| |
+---------------------------------------+
1 row in set (0.00 sec)
```
### 3. What did you see instead (Required)
```
mysql> select /*+ read_from_storage(tiflash[t1]) */ right(c1 , cast(c2 as unsigned)) from t1;
+----------------------------------+
| right(c1 , cast(c2 as unsigned)) |
+----------------------------------+
| k5tis |
| x |
| b |
+----------------------------------+
3 rows in set (0.01 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.