diff options
author | unknown <kaa@kaamos.(none)> | 2008-02-20 00:33:43 +0300 |
---|---|---|
committer | unknown <kaa@kaamos.(none)> | 2008-02-20 00:33:43 +0300 |
commit | 61c31af45d075e1aa1135b502209c04ca890425f (patch) | |
tree | 5543a0d99f0ea26b6a31aabda1379272bf9395dd /mysql-test | |
parent | 78e19d4283572f1706738980b8242a5e65619caf (diff) | |
download | mariadb-git-61c31af45d075e1aa1135b502209c04ca890425f.tar.gz |
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.
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/func_math.result | 19 | ||||
-rw-r--r-- | mysql-test/r/strict.result | 5 | ||||
-rw-r--r-- | mysql-test/t/func_math.test | 14 | ||||
-rw-r--r-- | mysql-test/t/strict.test | 1 |
4 files changed, 34 insertions, 5 deletions
diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index 6a476d12896..b4a07f18521 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -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 diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result index cc1a2535896..a257d0a8648 100644 --- a/mysql-test/r/strict.result +++ b/mysql-test/r/strict.result @@ -895,7 +895,6 @@ ERROR 22003: Out of range value for column 'col1' at row 1 INSERT INTO t1 (col2) VALUES ('-1.2E-3'); ERROR 22003: Out of range value for column 'col2' at row 1 UPDATE t1 SET col1 =col1 * 5000 WHERE col1 > 0; -ERROR 22003: Out of range value for column 'col1' at row 3 UPDATE t1 SET col2 =col2 / 0 WHERE col2 > 0; ERROR 22012: Division by 0 UPDATE t1 SET col2= MOD(col2,0) WHERE col2 > 0; @@ -923,10 +922,10 @@ SELECT * FROM t1; col1 col2 -2.2e-307 0 1e-303 0 -1.7e+308 1.7e+308 +NULL 1.7e+308 -2.2e-307 0 -2e-307 0 -1.7e+308 1.7e+308 +NULL 1.7e+308 0 NULL 2 NULL NULL NULL diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index 274a953a314..87b172a6436 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -248,5 +248,17 @@ INSERT INTO t1 VALUES ('a'); SELECT a DIV 2 FROM t1 UNION SELECT a DIV 2 FROM t1; DROP TABLE t1; - --echo End of 5.0 tests + +# +# Bug #31236: Inconsistent division by zero behavior for floating point numbers +# + +SELECT 1e308 + 1e308; +SELECT -1e308 - 1e308; +SELECT 1e300 * 1e300; +SELECT 1e300 / 1e-300; +SELECT EXP(750); +SELECT POW(10, 309); + +--echo End of 5.1 tests diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test index 2b71bf1093c..486f7ce7897 100644 --- a/mysql-test/t/strict.test +++ b/mysql-test/t/strict.test @@ -822,7 +822,6 @@ INSERT INTO t1 (col2) VALUES (-1.1E-3); INSERT INTO t1 (col1) VALUES ('+1.8E+309'); --error 1264 INSERT INTO t1 (col2) VALUES ('-1.2E-3'); ---error 1264 UPDATE t1 SET col1 =col1 * 5000 WHERE col1 > 0; --error 1365 UPDATE t1 SET col2 =col2 / 0 WHERE col2 > 0; |