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

different behavior from mysql planner with a condition caused error. #21625

Open
wshwsh12 opened this issue Dec 10, 2020 · 2 comments
Open

different behavior from mysql planner with a condition caused error. #21625

wshwsh12 opened this issue Dec 10, 2020 · 2 comments
Labels
severity/minor sig/execution SIG execution sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@wshwsh12
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE ttt (
a int(10) unsigned,
b int(10) unsigned
);
insert into ttt values(1,10),(20,2);
select * from ttt where a-b>0 and a = 1 and b = 9;

2. What did you expect to see? (Required)

In MySQL 8.0

MySQL [test]>  select * from ttt where a-b>0 and a = 1 and b = 9;
ERROR 1690 (22003): BIGINT UNSIGNED value is out of range in '(1 - 9)'

3. What did you see instead (Required)

[tidb]> select * from ttt where a-b>0 and a = 1 and b = 9;
Empty set (0.001 sec)
[tidb]> desc select * from ttt where a-b>0 and a = 1 and b = 9;
+-------------+---------+------+---------------+---------------+
| id          | estRows | task | access object | operator info |
+-------------+---------+------+---------------+---------------+
| TableDual_5 | 1.60    | root |               | rows:0        |
+-------------+---------+------+---------------+---------------+
1 row in set (0.001 sec)

4. What is your TiDB version? (Required)

6cd3c65

@wshwsh12 wshwsh12 added the type/bug The issue is confirmed as a bug. label Dec 10, 2020
@wshwsh12
Copy link
Contributor Author

Of course, it may be a MySQL bug. Because the condition is always false and it should get an empty result.

@zhangysh1995
Copy link

zhangysh1995 commented Dec 23, 2020

Of course, it may be a MySQL bug. Because the condition is always false and it should get an empty result.

@wshwsh12 I think it is probably not a bug in MySQL. You see that a and b are unsigned int, and a-b compute negative numbers in a signed case but it will cause an underflow in an unsigned case, where you will get a super big number as the result. It is reasonable that MySQL returned the out of range error. Therefore, the bug is in TiDB not in MySQL. Basically, the first predicate a-b>0 is always positive and the query should NOT return any result but should raise an error.

@yudongusa yudongusa added sig/community-infra sig/execution SIG execution and removed sig/planner SIG: Planner labels Aug 25, 2021
@tisonkun tisonkun added sig/sql-infra SIG: SQL Infra and removed sig/community-infra labels Sep 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/minor sig/execution SIG execution sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

5 participants