mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Fix for bug #31236: Inconsistent division by zero behavior for
floating point numbers Some math functions did not check if the result is a valid number (i.e. neither of +-inf or nan). Fixed by validating the result where necessary and returning NULL in case of invalid result. BitKeeper/deleted/.del-matherr.c: Rename: sql/matherr.c -> BitKeeper/deleted/.del-matherr.c configure.in: Removed DONT_USE_FINITE, it is not used anywhere. include/my_global.h: isfinite() is a C99 macro which absoletes finite(). First try to use it, then fall back to finite() if the target platform has it, otherwise use our own implementation. mysql-test/r/func_math.result: Added a test case for bug #31236. mysql-test/r/strict.result: Fixed a test case which relied on old behavior. mysql-test/t/func_math.test: Added a test case for bug #31236. mysql-test/t/strict.test: Fixed a test case which relied on old behavior. sql/field.cc: No need to check if the finite() or its equivalent is available. sql/item_func.cc: Use fix_result() wherever the result can be one of +-inf or nan, assuming the function arguments are valid numbers. Removed fix_result() from functions that are defined for all possible input numbers. sql/item_func.h: Moved fix_result() from Item_dec_func to Item_func which is a common ancestor for Item_dec_func and Item_num_op. sql/unireg.h: Removed POSTFIX_ERROR because no code returns it.
This commit is contained in:
@ -408,3 +408,22 @@ a DIV 2
|
||||
0
|
||||
DROP TABLE t1;
|
||||
End of 5.0 tests
|
||||
SELECT 1e308 + 1e308;
|
||||
1e308 + 1e308
|
||||
NULL
|
||||
SELECT -1e308 - 1e308;
|
||||
-1e308 - 1e308
|
||||
NULL
|
||||
SELECT 1e300 * 1e300;
|
||||
1e300 * 1e300
|
||||
NULL
|
||||
SELECT 1e300 / 1e-300;
|
||||
1e300 / 1e-300
|
||||
NULL
|
||||
SELECT EXP(750);
|
||||
EXP(750)
|
||||
NULL
|
||||
SELECT POW(10, 309);
|
||||
POW(10, 309)
|
||||
NULL
|
||||
End of 5.1 tests
|
||||
|
Reference in New Issue
Block a user