diff options
author | unknown <kaa@polly.local> | 2007-04-28 20:01:01 +0400 |
---|---|---|
committer | unknown <kaa@polly.local> | 2007-04-28 20:01:01 +0400 |
commit | 38090df9b566da89942f8a90fe71a3fac31efb9d (patch) | |
tree | b924ace3abe3cc30cdcc61b16cf06ad656fd2ad8 /mysql-test/t/func_math.test | |
parent | a491b2c116411d4c15aae04f3b0023cf92e97804 (diff) | |
download | mariadb-git-38090df9b566da89942f8a90fe71a3fac31efb9d.tar.gz |
Fix for bug #24912 "problems with bigint in abs() ceiling() round() truncate() mod()" and a number of related problems:
- unsigned flag was not handled correctly for a number of mathematical funcions, which led to incorrect results
- passing large values as the number of decimals to ROUND() resulted in incorrect results and even server crashes in some cases
- reverted the fix and the testcase for bug #10083 as it violates the manual
- fixed some testcases which relied on broken ROUND() behavior
mysql-test/r/func_math.result:
- Removed the testcase for bug #10083 (not a bug according to the manual)
- Changed the testcase for bug #9837 to expect a correct ROUND() behavior
- Added testcases for bug #24912 and all related bugs found
mysql-test/r/type_newdecimal.result:
Fixed a truncate() testcase which relied on broken behavior
mysql-test/t/func_math.test:
- Removed the testcase for bug #10083 (not a bug according to the manual)
- Changed the testcase for bug #9837 to expect a correct ROUND() behavior
- Added testcases for bug #24912 and all related bugs found
sql/item_func.cc:
Various changes to fix bug #24912 and all related bugs found:
- honor unsigned_flag in various Item_* functions
- correctly handle out-of-range numbers of decimals in Item_func_round::fix_length_and_dec()
- changed the argument specifying the number of decimals in my_double_round() from int to longlong, added a new argument to pass the 'unsigned flag'
- changed my_double_round() to correctly handle large values passed as the 'number of decimals' argument
- added a my_double_round() analog for BIGINT UNSIGNED arguments (my_unsigned_round())
- fixed Item_func_round()::int_op() to not overflow even when the result is within integer range
- fixed a bug Item_founc_round()::decimal_op() which resulted in crash when a large number of decimals was passed to my_decimal_round()
sql/item_func.h:
Various fixed to correctly handle unsigned values.
sql/item_strfunc.cc:
Changed the call to my_double_round() to match the new declaration.
sql/mysql_priv.h:
Changed the declaration for my_double_round() to be able pass arbitrary integers as number of decimals (both signed and unsigned)
Diffstat (limited to 'mysql-test/t/func_math.test')
-rw-r--r-- | mysql-test/t/func_math.test | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index 4041c267134..2ba07dfc581 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -83,11 +83,6 @@ drop table t1; # -# Bug #10083 (round doesn't increase decimals) -# -select round(150, 2); - -# # Bug @10632 (Ceiling function returns wrong answer) # select ceil(0.09); @@ -177,3 +172,37 @@ select format(t2.f2-t2.f1+1,0) from t1,t2 where t1.f2 = t2.f3 order by t1.f1; drop table t1, t2; set names default; + +# Bug 24912 -- misc functions have trouble with unsigned + +select cast(-2 as unsigned), 18446744073709551614, -2; +select abs(cast(-2 as unsigned)), abs(18446744073709551614), abs(-2); +select ceiling(cast(-2 as unsigned)), ceiling(18446744073709551614), ceiling(-2); +select floor(cast(-2 as unsigned)), floor(18446744073709551614), floor(-2); +select format(cast(-2 as unsigned), 2), format(18446744073709551614, 2), format(-2, 2); +select sqrt(cast(-2 as unsigned)), sqrt(18446744073709551614), sqrt(-2); +select round(cast(-2 as unsigned), 1), round(18446744073709551614, 1), round(-2, 1); +select round(4, cast(-2 as unsigned)), round(4, 18446744073709551614), round(4, -2); +select truncate(cast(-2 as unsigned), 1), truncate(18446744073709551614, 1), truncate(-2, 1); +select truncate(4, cast(-2 as unsigned)), truncate(4, 18446744073709551614), truncate(4, -2); +select round(10000000000000000000, -19), truncate(10000000000000000000, -19); +select round(1e0, -309), truncate(1e0, -309); +select round(1e1,308), truncate(1e1, 308); +select round(1e1, 2147483648), truncate(1e1, 2147483648); +select round(1.1e1, 4294967295), truncate(1.1e1, 4294967295); +select round(1.12e1, 4294967296), truncate(1.12e1, 4294967296); +select round(1.5, 2147483640), truncate(1.5, 2147483640); +select round(1.5, -2147483649), round(1.5, 2147483648); +select truncate(1.5, -2147483649), truncate(1.5, 2147483648); +select round(1.5, -4294967296), round(1.5, 4294967296); +select truncate(1.5, -4294967296), truncate(1.5, 4294967296); +select round(1.5, -9223372036854775808), round(1.5, 9223372036854775808); +select truncate(1.5, -9223372036854775808), truncate(1.5, 9223372036854775808); +select round(1.5, 18446744073709551615), truncate(1.5, 18446744073709551615); +select round(18446744073709551614, -1), truncate(18446744073709551614, -1); +select round(4, -4294967200), truncate(4, -4294967200); +select mod(cast(-2 as unsigned), 3), mod(18446744073709551614, 3), mod(-2, 3); +select mod(5, cast(-2 as unsigned)), mod(5, 18446744073709551614), mod(5, -2); +select pow(cast(-2 as unsigned), 5), pow(18446744073709551614, 5), pow(-2, 5); + +--echo End of 5.0 tests |