pingcap / pingcap/tidb

TiDB produces different results for SELECT statements (BIGINT value is out of range in '(8 - 100)')

Open
#34,222 3 comments 0 reactions 0 assignees View on GitHub
affects-4.0 affects-5.0 affects-5.1 affects-5.2 affects-5.3 affects-5.4 affects-6.0 severity/minor 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)

**Setup the environment:**

```
tiup playground --db.binpath /path/to/latest/tidb-server &
mysql -h "127.0.0.1" -u root -P 4000 -D testdb < mysql_bk.sql
```

_mysql_bk.sql:_
[mysql_bk.txt](https://github.com/pingcap/tidb/files/8555098/mysql_bk.txt)

**Testcase 1**
```
mysql -h "127.0.0.1" -u root -P 4000 -D testdb

mysql> delete from t_xa9msd;
mysql> select * from t_xa9msd as ref_0
where (63 & 72) - case when ref_0.wkey is NULL then 66 else 100 end > 88;
```

**Testcase 2**
```
mysql -h "127.0.0.1" -u root -P 4000 -D testdb

mysql> start transaction;
mysql> delete from t_xa9msd;
mysql> select * from t_xa9msd as ref_0
where (63 & 72) - case when ref_0.wkey is NULL then 66 else 100 end > 88;
mysql> commit;
```

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

The execution result of SELECT statements in Testcase 1 and Testcase 2 are same.

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

**Output of SELECT statement in Testcase 1**
```
Empty set (0.00 sec)
```

**Output of SELECT statement in Testcase 2**
```
ERROR 1690 (22003): BIGINT value is out of range in '(8 - 100)'
```

Their results are different.

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

```
Release Version: v6.1.0-alpha-173-g32b9c1477
Edition: Community
Git Commit Hash: 32b9c14779c2a7dd73003667d81bb42f67a33385
Git Branch: master
UTC Build Time: 2022-04-11 17:53:15
GoVersion: go1.18
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.