-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Incorrect result for query that uses an AND operator on floats #15743
Comments
@mrigger Thanks for your feedback. This is a bug and we will fix it soon. |
It's funny ... I find that MySQL also has this problem @mrigger :
But after investigating, I think the reason is that MySQL and TiDB round the second argument
I think we should let TiDB be compatible with MySQL, so the behavior is regarded as right... 🤣 |
It might be that I previously also reported this case to MySQL; I'll check. It's definitely a bug though, and the predicate should evaluate to mysql> SELECT (1 AND 0.4999) IS TRUE;
+------------------------+
| (1 AND 0.4999) IS TRUE |
+------------------------+
| 1 |
+------------------------+
1 row in set (0.01 sec)
mysql> SELECT (1 AND 0.5000) IS TRUE;
+------------------------+
| (1 AND 0.5000) IS TRUE |
+------------------------+
| 1 |
+------------------------+
1 row in set (0.00 sec) On a related note: #15725 is another instance for a bug that affected a previous version of MySQL, and was then fixed, but still affects TiDB. |
I just checked and found that the latest version of MySQL is not affected by this bug:
|
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.29 |
+-----------+
1 row in set (0.00 sec)
mysql> CREATE TABLE t0(c0 BOOL);
Query OK, 0 rows affected (0.01 sec)
mysql> INSERT INTO t0 VALUES (0);
Query OK, 1 row affected (0.01 sec)
mysql> SELECT * FROM t0 WHERE 1 AND 0.4;
Empty set (0.00 sec) MySQL 5.7 behaves differently, would you like to report a bug to the MySQL team, either? @mrigger |
I created a bug report in the MySQL bug tracker: https://bugs.mysql.com/bug.php?id=99120 Update: The bug has been verified. |
Consider the following statements:
Unexpectedly, the
SELECT
does not fetch any rows.1 AND 0.4
should evaluate to1
, which means that the whole predicate should evaluate toTRUE
. The negated predicate seems to correctly evaluate toFALSE
:I found this bug with the following environment:
The text was updated successfully, but these errors were encountered: