Bug #9854 hex() and out of range handling
Submitted: 12 Apr 2005 18:32 Modified: 18 Jul 2005 20:16
Reporter: Martin Friebe (Gold Quality Contributor) (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.11 OS:* / freebsd
Assigned to: Sergei Glukhov CPU Architecture:Any

[12 Apr 2005 18:32] Martin Friebe
Description:
the man page does not specificaly say, if hex() will do signed or unsigned calculation, but it says it is equal to conv(N, 10, 16), which according to the documentation treats the numbers as unsigned.

with a number like 2^63 + 1, both work unsigned

 select hex(9223372036854775809), conv(9223372036854775809,10,16);
+--------------------------+---------------------------------+
| hex(9223372036854775809) | conv(9223372036854775809,10,16) |
+--------------------------+---------------------------------+
| 8000000000000001         | 8000000000000001                |
+--------------------------+---------------------------------+

with a number greater than 2^64, the value returned by hex, makes no sense. vonv() returns what i expect to be correct.
 select hex(29223372036854775809), conv(29223372036854775809,10,16);
+---------------------------+----------------------------------+
| hex(29223372036854775809) | conv(29223372036854775809,10,16) |
+---------------------------+----------------------------------+
| 8000000000000000          | FFFFFFFFFFFFFFFF                 |
+---------------------------+----------------------------------+

How to repeat:
select hex(9223372036854775809), conv(9223372036854775809,10,16);

select hex(29223372036854775809), conv(29223372036854775809,10,16);

Suggested fix:
-
[11 Jul 2005 15:24] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/26896
[13 Jul 2005 4:14] Alexander Barkov
Ok to push.
[13 Jul 2005 9:17] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/26981
[13 Jul 2005 9:19] Sergei Glukhov
Fixed in 4.1.13
[18 Jul 2005 20:16] Paul DuBois
Noted in 4.1.13 changelog.