Bug #1769 | Problems with MAX-function | ||
---|---|---|---|
Submitted: | 6 Nov 2003 9:16 | Modified: | 13 Nov 2003 6:20 |
Reporter: | Timo Leppänen | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: MyISAM storage engine | Severity: | S2 (Serious) |
Version: | 4.0.15-standard | OS: | Linux (Linux) |
Assigned to: | CPU Architecture: | Any |
[6 Nov 2003 9:16]
Timo Leppänen
[12 Nov 2003 13:46]
Dean Ellis
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.mysql.com/documentation/ and the instructions on how to report a bug at http://bugs.mysql.com/how-to-report.php The return value appears to be what one would expect when subtracting unsigned integers in such a manner that the result would be negative.
[13 Nov 2003 3:54]
Timo Leppänen
So why there isn't this kind of 'feature' in 3.23?
[13 Nov 2003 6:20]
Sergei Golubchik
Because 3.23 uses signed arithmetics when subtracting unsigned numbers. You can turn this mode on in 4.0 by using --sql-mode=NO_UNSIGNED_SUBTRACTION (see the manual) without NO_UNSIGNED_SUBTRACTION: mysql> select 18446744073709551615-5, 18446744073709551610-18446744073709551615; +------------------------+-------------------------------------------+ | 18446744073709551615-5 | 18446744073709551610-18446744073709551615 | +------------------------+-------------------------------------------+ | 18446744073709551610 | 18446744073709551611 | +------------------------+-------------------------------------------+ 1 row in set (0.00 sec) with NO_UNSIGNED_SUBTRACTION: mysql> select 18446744073709551615-5, 18446744073709551610-18446744073709551615; +------------------------+-------------------------------------------+ | 18446744073709551615-5 | 18446744073709551610-18446744073709551615 | +------------------------+-------------------------------------------+ | -6 | -5 | +------------------------+-------------------------------------------+ 1 row in set (0.00 sec)