-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
The results of condition = and <= have no implication to each other #50785
Comments
Could you please confirm whether the simplification process we applied has been helpful for developers in diagnosing and addressing this issue? query1: (SELECT (`f7`+SIGN(0.02087047389286014)) AS `f2`,(DATE_ADD(NULL, INTERVAL 1 HOUR_SECOND)) AS `f3` FROM
(SELECT `col_bigint_key_signed` AS `f7`,`col_double_key_signed` AS `f8` FROM `table_7_utf8_undef`) AS `t2` WHERE
((-`f8`)<=ANY (SELECT `col_char(20)_key_signed` FROM `table_3_utf8_undef` ))
HAVING (DATE_ADD(`f3`, INTERVAL 1 DAY_HOUR ) IS FALSE) IS FALSE);
result1: +------+------+
| f2 | f3 |
+------+------+
| 2 | NULL |
| -8 | NULL |
| 2 | NULL |
| 0 | NULL |
| 1 | NULL |
+------+------+
5 rows in set, 7 warnings (0.002 sec)
query2: (SELECT (`f7`+SIGN(0.02087047389286014)) AS `f2`,(DATE_ADD(NULL, INTERVAL 1 HOUR_SECOND)) AS `f3` FROM
(SELECT `col_bigint_key_signed` AS `f7`,`col_double_key_signed` AS `f8` FROM `table_7_utf8_undef`) AS `t2` WHERE
((-`f8`)=ANY (SELECT `col_char(20)_key_signed` FROM `table_3_utf8_undef` ) )
HAVING (DATE_ADD(`f3`, INTERVAL 1 DAY_HOUR ) IS FALSE) IS FALSE);
result2: +------+------+
| f2 | f3 |
+------+------+
| 108 | NULL |
| 1 | NULL |
| 39 | NULL |
+------+------+
3 rows in set, 7 warnings (0.003 sec)
|
@akuluasan I think the simplified version can help us rule out the CTE. |
Analyze: mysql> SELECT `col_bigint_key_signed` AS `f7`,`col_double_key_signed` FROM `table_7_utf8_undef` WHERE( (-col_double_key_signed) <=ANY(SELECT `col_char(20)_key_signed` FROM `table_3_utf8_undef`)) ;
+------+-----------------------+
| f7 | col_double_key_signed |
+------+-----------------------+
| 1 | 0.0001 |
| -9 | 12.991 |
| 1 | 2 |
| -1 | 1.009 |
| 0 | 0 |
+------+-----------------------+
5 rows in set, 7 warnings (0.00 sec)
mysql> SELECT `col_bigint_key_signed` AS `f7`,`col_double_key_signed` FROM `table_7_utf8_undef` WHERE( (-col_double_key_signed) =ANY(SELECT `col_char(20)_key_signed` FROM `table_3_utf8_undef`)) ;
+------+-----------------------+
| f7 | col_double_key_signed |
+------+-----------------------+
| 107 | -1 |
| 0 | 0 |
| 38 | -1 |
+------+-----------------------+
3 rows in set, 7 warnings (0.00 sec)
And mysql> SELECT `col_char(20)_key_signed` FROM `table_3_utf8_undef`;
+-------------------------+
| col_char(20)_key_signed |
+-------------------------+
| 1 |
| 3
|
| w |
+-------------------------+
3 rows in set (0.00 sec)
mysql> SELECT max(`col_char(20)_key_signed`) FROM `table_3_utf8_undef`;
+--------------------------------+
| max(`col_char(20)_key_signed`) |
+--------------------------------+
| w |
+--------------------------------+
1 row in set (0.01 sec) w will cast to 0 when compared with the |
Thanks for the Analyze! |
/severity major |
From this analyze, it seems not proper to rewrite this ANY to <= max, because it's not fully equivalent when implicit casting exists. Change to planner issue. |
/remove-sig execution |
/sig planner |
The <= ANY rewrite to <= MAX is a correctly rewrite. |
Reproduce step
|
Still have the same problem in v6.5
|
Bug Report
When I use a more restrictive condition, the query results should be a subset of the previous one, but now there are values outside the set.
1. Minimal reproduce step (Required)
create table
query1:
query2:
2. What did you expect to see? (Required)
Because = is more binding than <=, result1 should contain result2
3. What did you see instead (Required)
result1:
result2:
4. What is your TiDB version? (Required)
8.0.11-TiDB-v7.5.0
The text was updated successfully, but these errors were encountered: