PRIMARY KEY should not change the query result
- 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)
Run the following two test cases and observe their query results.
Case 1:
```SQL
CREATE TABLE t0(c0 char(1) PRIMARY KEY );
INSERT INTO t0 VALUES ('1');
SELECT * FROM t0 WHERE (- ((~ (((t0.c0) IS NULL))))); -- 1
```
Case 2:
```SQL
CREATE TABLE t0(c0 char(1));
INSERT INTO t0 VALUES ('1');
SELECT * FROM t0 WHERE (- ((~ (((t0.c0) IS NULL))))); -- ERROR 1690 (22003): BIGINT value is out of range in '-18446744073709551615'
```
### 2. What did you expect to see? (Required)
The query result in case 1 and case 2 should be the same, either both return 1 or both return error.
### 3. What did you see instead (Required)
case 1 returns a normal result, while case 2 returns an error
### 4. What is your TiDB version? (Required)
```SQL
Release Version: v6.6.0
Edition: Community
Git Commit Hash: f4ca0821fb96a2bdd37d2fb97eb26c07fc58d4e4
Git Branch: heads/refs/tags/v6.6.0
UTC Build Time: 2023-02-17 14:49:02
GoVersion: go1.19.5
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv
```
Contributor guide
Assessment
This issue has not been assessed yet.