Bug #79902 Function GREATEST and LEAST works incorrectly with bigint unsigned value
Submitted: 9 Jan 2016 15:46 Modified: 19 Jan 2016 17:23
Reporter: Su Dylan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DML Severity:S2 (Serious)
Version:5.7.8, 5.5.48, 5.6.28, 5.7.10 OS:Any
Assigned to: CPU Architecture:Any

[9 Jan 2016 15:46] Su Dylan
Description:
Output:
=====
mysql> select greatest( 9223372036854775807 , 9223372036854775808 );
+-------------------------------------------------------+
| greatest( 9223372036854775807 , 9223372036854775808 ) |
+-------------------------------------------------------+
|                                   9223372036854775807 |
+-------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select least( 9223372036854775807 , 9223372036854775808 );
+----------------------------------------------------+
| least( 9223372036854775807 , 9223372036854775808 ) |
+----------------------------------------------------+
|                               -9223372036854775808 |
+----------------------------------------------------+
1 row in set (0.00 sec)

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.8-rc  |
+-----------+
1 row in set (0.00 sec)

Problem:
=====

How to repeat:
select greatest( 9223372036854775807 , 9223372036854775808 );
select least( 9223372036854775807 , 9223372036854775808 );

Suggested fix:
With bigint unsigned values, GREATEST/LEAST work as expected.
[11 Jan 2016 7:27] MySQL Verification Team
Hello Su Dylan,

Thank you for the report and test case.
Observed that 5.5.48/5.6.28/5.7.10 are affected.

Thanks,
Umesh
[19 Jan 2016 17:23] Paul DuBois
Noted in 5.8.0 changelog.

GREATEST() and LEAST() treated all integer input as signed.