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

incorrect result while part or condition expr failed #25734

Open
aytrack opened this issue Jun 24, 2021 · 9 comments
Open

incorrect result while part or condition expr failed #25734

aytrack opened this issue Jun 24, 2021 · 9 comments
Assignees
Labels
affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 affects-6.2 affects-6.3 affects-6.4 affects-6.5 affects-6.6 affects-7.0 affects-7.1 affects-7.5 affects-8.1 severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@aytrack
Copy link
Contributor

aytrack commented Jun 24, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

deploy a cluster with tikv

create table t2 (a bigint unsigned);
insert into t2 values (18446744073709551615);
select * from t2 where a > 10 or a  + 10 >= 18446744073709551615 + 10;

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

MySQL test> select * from t2 where a > 10 or a  + 10 >= 18446744073709551615 + 10;
+----------------------+
| a                    |
+----------------------+
| 18446744073709551615 |
+----------------------+

3. What did you see instead (Required)

MySQL root@172.16.5.105:test> select * from t2 where a > 10 or a  + 10 >= 18446744073709551615 + 10;
(1690, "BIGINT UNSIGNED value is out of range in '(10 + -1)'")

4. What is your TiDB version? (Required)

release-5.1: 7784454
master: aaed434

@aytrack aytrack added type/bug The issue is confirmed as a bug. sig/execution SIG execution severity/major labels Jun 24, 2021
@lzmhhh123 lzmhhh123 self-assigned this Jun 28, 2021
@fuzhe1989
Copy link
Contributor

any update? @lzmhhh123

@lzmhhh123
Copy link
Contributor

This is because when eval condition a > 10 or a + 10 >= 18446744073709551615 + 10. TiDB only execute a > 10 then assets the condition is ture. But coprocessor must execute a > 10 and a+10 >= 18446744073709551615 + 10 both. So the tikv rises the error.

@fuzhe1989
Copy link
Contributor

tiflash doesn't have this issue.

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Nov 30, 2021

TiDB and TiKV both have the problem.

@fuzhe1989
Copy link
Contributor

/assign @XuHuaiyu

@yibin87
Copy link
Contributor

yibin87 commented Dec 1, 2021

Try mysql, it seems in some cases, it will also execute the second comparison and report an overflow error:
mysql> select * from t2 where a > 10 or a >= 18446744073709551615 + 10;
ERROR 1690 (22003): BIGINT UNSIGNED value is out of range in '(18446744073709551615 + 10)'
So overflow calculations => ERROR seems reasonable.
The real problems may be

  1. Inconsistency between tidb and tiflash
  2. The TiDB error message: '(10 + -1)', converting BigInt Unsigned to BigInt, not user friendly.

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Dec 1, 2021

Confirmed in TiDB with and without pushing down "or", both cases work successfully.

@XuHuaiyu XuHuaiyu removed their assignment Dec 1, 2021
@yibin87
Copy link
Contributor

yibin87 commented Dec 1, 2021

Confirmed in TiDB with and without pushing down "or", both cases work successfully.

You mean, TiDB won't report error message in the latest version for this case? @XuHuaiyu

@fuzhe1989
Copy link
Contributor

@yibin87 Huaiyu means TiDB itself won't report error message in such case. Neither during constant-folding nor the execution of logical-or function (TiDB version). Actually it's the TiKV reported the error.

@jebter jebter added affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. labels Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 affects-6.2 affects-6.3 affects-6.4 affects-6.5 affects-6.6 affects-7.0 affects-7.1 affects-7.5 affects-8.1 severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

8 participants