pingcap / pingcap/tidb

Different evaluation result for the constant -1E19

Open
#32,720 0 comments 0 reactions 0 assignees View on GitHub
severity/moderate 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)
```sql
DROP TABLE IF EXISTS t0;
CREATE TABLE t0 (c0 TEXT);
INSERT INTO t0 VALUES ('a');
SELECT * FROM t0 WHERE -1E19 ^ t0.c0;
SHOW WARNINGS;
UPDATE t0 SET c0 = 'b' WHERE -1E19 ^ t0.c0;
SHOW WARNINGS;
```

### 2. What did you expect to see? (Required)
The warning message should be same for the constant -1E19.
### 3. What did you see instead (Required)
SELECT returned the following warnings, where the constant -1E19 overflows bigint.
```sql
+---------+------+-----------------------------------------------------------+
| Level | Code | Message |
+---------+------+-----------------------------------------------------------+
| Warning | 1690 | constant -1e+19 overflows bigint |
| Warning | 1292 | evaluation failed: Truncated incorrect INTEGER value: 'a' |
+---------+------+-----------------------------------------------------------+
2 rows in set (0.00 sec)
```
UPDATE returned the following warnings, where the constant -1E19 overflows LongLong
```sql
+-------+------+---------------------------------------------------+
| Level | Code | Message |
+-------+------+---------------------------------------------------+
| Error | 1690 | constant -10000000000000000000 overflows LongLong |
+-------+------+---------------------------------------------------+
1 row in set (0.00 sec)
```
Are these two warning messages meaning the same result?
### 4. What is your TiDB version? (Required)
```sql
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()

|
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v5.4.0
Edition: Community
Git Commit Hash: 55f3b24c1c9f506bd652ef1d162283541e428872
Git Branch: heads/refs/tags/v5.4.0
UTC Build Time: 2022-01-25 08:39:26
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
```

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.