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

Wrong result for greatest when args are unsigned bigint #30101

Closed
guo-shaoge opened this issue Nov 24, 2021 · 3 comments · Fixed by #30121
Closed

Wrong result for greatest when args are unsigned bigint #30101

guo-shaoge opened this issue Nov 24, 2021 · 3 comments · Fixed by #30121
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. severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@guo-shaoge
Copy link
Collaborator

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table t1;
create table t1(c1 bigint unsigned, c2 bigint unsigned);
insert into t1 values(9223372036854775808, 9223372036854775809);
select greatest(c1, c2) from t1;

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

mysql> select greatest(c1, c2) from t2;
+---------------------+
| greatest(c1, c2)    |
+---------------------+
| 9223372036854775808 |
+---------------------+
1 row in set (0.01 sec)

3. What did you see instead (Required)

mysql> select greatest(c1, c2) from t1;
+----------------------+
| greatest(c1, c2)     |
+----------------------+
| -9223372036854775807 |
+----------------------+
1 row in set (0.01 sec)

4. What is your TiDB version? (Required)

master

@guo-shaoge guo-shaoge added the type/bug The issue is confirmed as a bug. label Nov 24, 2021
@sylzd
Copy link
Contributor

sylzd commented Nov 24, 2021

/assign

@sylzd
Copy link
Contributor

sylzd commented Nov 24, 2021

the expected result is

mysql> select greatest(c1, c2) from t2;
+---------------------+
| greatest(c1, c2)    |
+---------------------+
| 9223372036854775809 |
+---------------------+
1 row in set (0.01 sec)

@github-actions
Copy link

github-actions bot commented Dec 2, 2021

Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.

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. severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants