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

P0-[4.0 bug hunting]-[WHERE clause]-Wrong NULL value evaluation result in INCORRECT query results #64

Open
zhangysh1995 opened this issue Apr 26, 2020 · 7 comments

Comments

@zhangysh1995
Copy link

Bug Report

1. What did you do?

Running wreck-it with the default command line.

mysql> desc table_int_float;
+-----------+---------+------+------+---------+----------------+
| Field     | Type    | Null | Key  | Default | Extra          |
+-----------+---------+------+------+---------+----------------+
| id        | int(16) | NO   | PRI  | NULL    | auto_increment |
| col_int   | int(16) | YES  |      | NULL    |                |
| col_float | float   | YES  | MUL  | NULL    |                |
+-----------+---------+------+------+---------+----------------+
3 rows in set (0.00 sec)

mysql> select col_float from table_varchar_float;
+-----------+
| col_float |
+-----------+
|      NULL |
|        -1 |
|      -0.1 |
|      NULL |
|       1.5 |
|       0.1 |
|      NULL |
|      NULL |
|         0 |
|       0.5 |
|      NULL |
|      NULL |
|      -0.1 |
|         1 |
|      NULL |
|       1.5 |
|      NULL |
|      NULL |
|      NULL |
+-----------+
19 rows in set (0.00 sec)

mysql> SELECT * FROM table_varchar_float WHERE !(table_varchar_float.col_float and 1) IS NULL;
Empty set (0.00 sec)

2. What did you expect to see?

It should return some rows in the table (where the col_float=NULL).

mysql> select !(NULL and 1) is NULL;
+-----------------------+
| !(NULL and 1) is NULL |
+-----------------------+
|                     1 |
+-----------------------+
1 row in set (0.00 sec)

3. What did you see instead?

It returns empty set.

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 zhangysh1995 changed the title P0-[4.0 bug hunting]-[WHERE clause]- wrong NULL value evaluation P0-[4.0 bug hunting]-[WHERE clause]-Wrong NULL value evaluation Apr 26, 2020
@shuke987
Copy link

/bug P1

@sre-bot sre-bot added bug/P1 and removed bug/P2 labels Apr 27, 2020
@zhangysh1995
Copy link
Author

zhangysh1995 commented Apr 27, 2020

@shuke987 Not sure why this is P1 but not P0, it could cause wrong return results. Could you explain the reason that I could better tag the later new bugs?

@zhangysh1995 zhangysh1995 changed the title P0-[4.0 bug hunting]-[WHERE clause]-Wrong NULL value evaluation P0-[4.0 bug hunting]-[WHERE clause]-Wrong NULL value evaluation result in INCORRECT query results Apr 27, 2020
@SunRunAway
Copy link

@Reminiscent
Is this issue the same problem that pingcap/tidb#16542 will resolve?

@Reminiscent
Copy link

@SunRunAway Sure. This issue can be fixed by #16542. Should we close this issue?

@SunRunAway
Copy link

SunRunAway commented May 7, 2020

@shuke987 This issue is fixed by pingcap/tidb#16542 and can be closed.

@shuke987
Copy link

shuke987 commented May 8, 2020

@zhangysh1995 hi, this is a bug which causes wrong return results, but it is an expression corner case. We treat these corner cases as P1 bug.

@zhangysh1995
Copy link
Author

@zhangysh1995 hi, this is a bug which causes wrong return results, but it is an expression corner case. We treat these corner cases as P1 bug.

Thanks for the explanation! You may close the issue now! @shuke987

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

6 participants