pingcap / tidb

TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
https://pingcap.com
Apache License 2.0
36.96k stars 5.81k forks source link

Inconsistenet error reporting format with MySQL #22399

Open Tjianke opened 3 years ago

Tjianke commented 3 years ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

 select cast(-1 as unsigned) + 9223372036854775808;

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

(1690, "BIGINT UNSIGNED value is out of range in '(cast(-(1) as unsigned) + 9223372036854775808)'")

3. What did you see instead (Required)

(1690, "BIGINT UNSIGNED value is out of range in '(18446744073709551615 + 9223372036854775808)'")

4. What is your TiDB version? (Required)

+-------------------------------------------------------------------+
| tidb_version()                                                    |
+-------------------------------------------------------------------+
| Release Version: v4.0.0-beta.2-2016-g3dd842f50                    |
| Edition: Community                                                |
| Git Commit Hash: 3dd842f50a75ebbf9a4f9d7b30fb2ce8a8dd4b37         |
| Git Branch: master                                                |
| UTC Build Time: 2021-01-13 14:08:28                               |
| GoVersion: go1.15.5                                               |
| Race Enabled: false                                               |
| TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306 |
| Check Table Before Drop: false                                    |
+-------------------------------------------------------------------+
cyliu0 commented 3 years ago

It looks like the similar issues you filed yesterday. Can we merge all of them into one?

Tjianke commented 3 years ago

It looks like the similar issues you filed yesterday. Can we merge all of them into one?

Well, to be precise, this issue is a compatibility issue with MySQL(sry could not find a compatibility category in issue, so I used bug category instead). Other issues I raised before are actually bugs, where errors should raise.

However, I think it may be more concise if we merge those two bug issues together and left this compatibility issue alone?

Tjianke commented 3 years ago

Seems like this issue won't have a quick fix, due to the fact that incompatbility raises from this line:

return types.ErrOverflow.GenWithStackByArgs("BIGINT UNSIGNED", fmt.Sprintf("(%s - %s)", b.args[0].String(), b.args[1].String()))

b.args[1].String() could only return the eventual parsed value of an expression instead of original args in SQL query(what MySQL is returning).

Tjianke commented 3 years ago

same issue as #11181