Different warning messages for the same expression
- 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 INT NOT NULL);
INSERT INTO t0 VALUES(1);
SELECT * FROM t0 WHERE (CASE 0 WHEN 'a' THEN c0 END) NOT LIKE DEFAULT(c0);
SHOW WARNINGS; -- SELECT
UPDATE t0 SET c0 = 2 WHERE (CASE 0 WHEN 'a' THEN c0 END) NOT LIKE DEFAULT(c0);
SHOW WARNINGS; -- UPDATE
```
### 2. What did you expect to see? (Required)
The where clause is the same between SELECT and UPDATE, but they generate different warnings. I think the data truncate error also happens in UPDATE statement, but actually not.
### 3. What did you see instead (Required)
```sql
mysql> SHOW WARNINGS; -- SELECT
+---------+------+-----------------------------------------+
| Level | Code | Message |
+---------+------+-----------------------------------------+
| Warning | 1292 | Truncated incorrect DOUBLE value: 'a' |
| Error | 1364 | Field 'c0' doesn't have a default value |
+---------+------+-----------------------------------------+
2 rows in set (0.00 sec)
mysql> SHOW WARNINGS; -- UPDATE
+-------+------+-----------------------------------------+
| Level | Code | Message |
+-------+------+-----------------------------------------+
| Error | 1364 | Field 'c0' doesn't have a default value |
+-------+------+-----------------------------------------+
1 row in set (0.00 sec)
```
### 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
Assessment
This issue has not been assessed yet.