Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double negation causes incorrect result #15725

Closed
mrigger opened this issue Mar 26, 2020 · 4 comments · Fixed by #16108
Closed

Double negation causes incorrect result #15725

mrigger opened this issue Mar 26, 2020 · 4 comments · Fixed by #16108
Assignees
Labels

Comments

@mrigger
Copy link

mrigger commented Mar 26, 2020

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 mrigger added the type/bug The issue is confirmed as a bug. label Mar 26, 2020
@shenli
Copy link
Member

shenli commented Mar 26, 2020

@mrigger Thanks for your report! We will fix it soon.

@zz-jason
Copy link
Member

@XuHuaiyu PTAL

@mrigger
Copy link
Author

mrigger commented Mar 27, 2020

Btw, it seems that I found the same or a similar bug in MySQL: https://bugs.mysql.com/bug.php?id=95900

@XuHuaiyu XuHuaiyu self-assigned this Mar 30, 2020
@SunRunAway SunRunAway added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. and removed help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Mar 30, 2020
@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Apr 2, 2020

This problem can not be reproduced on the master branch because of #12687.
I'll try to fix it on release-3.0, release-3.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants