Consider the following statements:
CREATE TABLE t0(c0 INT);
INSERT INTO t0(c0) VALUES (2);
SELECT t0.c0 FROM t0 WHERE (NOT NOT t0.c0) = t0.c0; -- expected: {}, actual: {2}
Unexpectedly, a row is fetched. The predicate (NOT NOT t0.c0) = t0.c0. should evaluate to false. I suspect that the double negation is removed, which is incorrect, since NOT NOT t0.c0 should evaluate to 1, and not to 2.
Here is the environment that I used:
mysql> select tidb_version();
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v3.0.12
Git Commit Hash: 8c4696b3f3408c61dd7454204ddd67c93501609a
Git Branch: heads/refs/tags/v3.0.12
UTC Build Time: 2020-03-16 09:56:22
GoVersion: go version go1.13 linux/amd64
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
@mrigger Thanks for your report! We will fix it soon.
@XuHuaiyu PTAL
Btw, it seems that I found the same or a similar bug in MySQL: https://bugs.mysql.com/bug.php?id=95900
This problem can not be reproduced on the master branch because of https://github.com/pingcap/tidb/pull/12687.
I'll try to fix it on release-3.0, release-3.1.
Most helpful comment
@mrigger Thanks for your report! We will fix it soon.