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

P1-[4.0 bug hunting]-[WHERE Clause]-Wrong evaluation of binary operator #68

Open
zhangysh1995 opened this issue Apr 29, 2020 · 9 comments

Comments

@zhangysh1995
Copy link

zhangysh1995 commented Apr 29, 2020

Bug Report

1. What did you do?

mysql> desc view_3;
+---------------+--------------+------+------+---------+----------------+
| Field         | Type         | Null | Key  | Default | Extra          |
+---------------+--------------+------+------+---------+----------------+
| id_6          | int(16)      | NO   | PRI  | NULL    | auto_increment |
| col_int_6     | int(16)      | YES  |      | NULL    |                |
| col_float_6   | float        | YES  |      | NULL    |                |
| col_varchar_6 | varchar(511) | YES  |      | NULL    |                |
| id_0          | int(16)      | NO   | PRI  | NULL    | auto_increment |
| col_int_0     | int(16)      | NO   | PRI  | NULL    |                |
| id_2          | int(16)      | NO   | PRI  | NULL    | auto_increment |
| col_varchar_2 | varchar(511) | YES  |      | NULL    |                |
+---------------+--------------+------+------+---------+----------------+

mysql> select * from view_3;
+------+-----------+-------------+---------------+------+-----------+------+---------------------+
| id_6 | col_int_6 | col_float_6 | col_varchar_6 | id_0 | col_int_0 | id_2 | col_varchar_2       |
+------+-----------+-------------+---------------+------+-----------+------+---------------------+
|   10 |     65535 |        NULL | 1             |    4 |         0 |    7 | NULL                |
|   10 |     65535 |        NULL | 1             |    4 |         0 |    8 | NULL                |
|   10 |     65535 |        NULL | 1             |    4 |         0 |    9 | 1                   |
|   10 |     65535 |        NULL | 1             |    4 |         0 |   10 | 0000-00-00 00:00:00 |
|   10 |     65535 |        NULL | 1             |    4 |         0 |   11 | false               |
|   10 |     65535 |        NULL | 1             |    4 |         0 |   12 | NULL                |
|   10 |     65535 |        NULL | 1             |    4 |         0 |   13 | NULL                |
|   10 |     65535 |        NULL | 1             |    5 |         0 |    1 | NULL                |
|   10 |     65535 |        NULL | 1             |    5 |         0 |    2 | 2020-02-02 02:02:00 |
|   10 |     65535 |        NULL | 1             |    5 |         0 |    3 | 0000-00-00 00:00:00 |
|   10 |     65535 |        NULL | 1             |    5 |         0 |    4 |                     |
|   10 |     65535 |        NULL | 1             |    5 |         0 |    5 | NULL                |
|   10 |     65535 |        NULL | 1             |    5 |         0 |    6 | false               |
|   10 |     65535 |        NULL | 1             |    5 |         0 |    7 | NULL                |
+------+-----------+-------------+---------------+------+-----------+------+---------------------+
14 rows in set (0.00 sec)

mysql> SELECT view_3.id_6 FROM view_3 WHERE 1.5489864675860129e-02 AND view_3.id_6;
Empty set (0.00 sec)

2. What did you expect to see?

All rows returned.

3. What did you see instead?

mysql> SELECT view_3.id_6 FROM view_3 WHERE 1.5489864675860129e-02 AND view_3.id_6;
Empty set (0.00 sec)

4. What version of TiDB are you using? (tidb-server -V or run select tidb_version(); on TiDB)

mysql> select tidb_version();
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                        |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v4.0.0-rc
Git Commit Hash: 79db9e30ab8f98ac07c8ae55c66dfecc24b43d56
Git Branch: heads/refs/tags/v4.0.0-rc
UTC Build Time: 2020-04-08 07:32:25
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
@zhangysh1995
Copy link
Author

@shuke987 It seems this issue hasn't got any update. Do you have any comments on it?

@wjhuang2016
Copy link

Hi, @zhangysh1995
Thanks for your bug report. Could you give us some data and schema so that we can reproduce the bug?

@zhangysh1995
Copy link
Author

@wjhuang2016 Provided a trimmed case as following:

mysql> create table t0(id int(16) primary key auto_increment not null);
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t0(id) values(1);
Query OK, 1 row affected (0.00 sec)

mysql> insert into t0(id) values(2);
Query OK, 1 row affected (0.00 sec)

mysql> insert into t0(id) values(3);
Query OK, 1 row affected (0.00 sec)

mysql> select id from t0 where id;
+----+
| id |
+----+
|  1 |
|  2 |
|  3 |
+----+
3 rows in set (0.00 sec)

mysql> select id from t0 where id and 1.5489864675860129e-02;
Empty set (0.00 sec)

mysql> select 1 and 1.5489864675860129e-02;
+------------------------------+
| 1 and 1.5489864675860129e-02 |
+------------------------------+
|                            1 |
+------------------------------+
1 row in set (0.00 sec)

@wjhuang2016
Copy link

Hi, @zhangysh1995
I think this bug has been fixed by this PR. And I can't reproduce it in the master branch.

@zhangysh1995
Copy link
Author

Hi, @zhangysh1995
I think this bug has been fixed by this PR. And I can't reproduce it in the master branch.

Looks like it was fixed.

@zhangysh1995
Copy link
Author

zhangysh1995 commented May 17, 2020

It seems I should move to master branch for testing now.

@wjhuang2016
Copy link

It seems I should move to master branch for testing now.

Yeah, we have fixed many bugs since the 4.0.0 rc, it's better to use the master branch.

@shuke987
Copy link

Or you can try 4.0.0-RC2

@shuke987
Copy link

shuke987 commented Jun 2, 2020

/bug P1

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

No branches or pull requests

4 participants