Consider the following statements:
CREATE TABLE t0(c0 DOUBLE UNSIGNED UNIQUE);
INSERT INTO t0(c0) VALUES (0);
SELECT * FROM t0 WHERE t0.c0 = -1; -- expected: {}, actual: {0}
Unexpectedly, the SELECT fetches a row. It seems that DOUBLE and FLOAT is affected, but not INT and NUMERIC.
Environment:
mysql> select tidb_version();
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v4.0.0-beta.2-167-gaa7ef9c46
Git Commit Hash: aa7ef9c46435bb20d42fa0badcf09fc16f9609a9
Git Branch: master
UTC Build Time: 2020-04-02 09:15:47
GoVersion: go1.13.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
Hi, is anyone working on this? I have a simple patch that seems can fix this issue, although I am not sure whether it will introduce other issues.
Maybe I can create a pull request if nobody working on this.
@sduzh Of course. I just found out where the problem is and have not submitted a PR. The problem is in the place you mentioned, welcome to submit PR!
@sduzh The problem is that this line of code incorrectly handles the overflow error. It causes the result to return 0. I am not sure whether your patch will introduce new problems, feel free to work on this issue. Thanks for your contribution!
I quit this issue.
In the master 93c3e6becd5929cc37901d78d1f679cbc5d86342, the result is correct.
mysql> CREATE TABLE t0(c0 DOUBLE UNSIGNED UNIQUE);
Query OK, 0 rows affected (0.01 sec)
mysql> INSERT INTO t0(c0) VALUES (0);
Query OK, 1 row affected (0.00 sec)
mysql> SELECT * FROM t0 WHERE t0.c0 = -1;
Empty set (0.00 sec)
Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: https://github.com/pingcap/tidb/issues/20100
Most helpful comment
Hi, is anyone working on this? I have a simple patch that seems can fix this issue, although I am not sure whether it will introduce other issues.
Maybe I can create a pull request if nobody working on this.