Skip to content

Wrong result for greatest when args are unsigned bigint #30101

@guo-shaoge

Description

@guo-shaoge

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

Metadata

Metadata

Assignees

Labels

affects-5.0This bug affects 5.0.x versions.affects-5.1This bug affects 5.1.x versions.affects-5.2This bug affects 5.2.x versions.affects-5.3This bug affects 5.3.x versions.severity/majorsig/executionSIG executiontype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions