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 /include/my_global.h | |
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 'include/my_global.h')
-rw-r--r-- | include/my_global.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/include/my_global.h b/include/my_global.h index 4b0786aa826..26412d4102e 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -486,9 +486,6 @@ C_MODE_END #include <sys/stream.h> /* HPUX 10.20 defines ulong here. UGLY !!! */ #define HAVE_ULONG #endif -#ifdef DONT_USE_FINITE /* HPUX 11.x has is_finite() */ -#undef HAVE_FINITE -#endif #if defined(HPUX10) && defined(_LARGEFILE64_SOURCE) && defined(THREAD) /* Fix bug in setrlimit */ #undef setrlimit @@ -858,9 +855,13 @@ typedef SOCKET_SIZE_TYPE size_socket; #define SIZE_T_MAX ~((size_t) 0) #endif -#ifndef HAVE_FINITE +#ifndef isfinite +#ifdef HAVE_FINITE +#define isfinite(x) finite(x) +#else #define finite(x) (1.0 / fabs(x) > 0.0) -#endif +#endif /* HAVE_FINITE */ +#endif /* isfinite */ #ifndef HAVE_ISNAN #define isnan(x) ((x) != (x)) @@ -870,7 +871,7 @@ typedef SOCKET_SIZE_TYPE size_socket; /* isinf() can be used in both C and C++ code */ #define my_isinf(X) isinf(X) #else -#define my_isinf(X) (!finite(X) && !isnan(X)) +#define my_isinf(X) (!isfinite(X) && !isnan(X)) #endif /* Define missing math constants. */ |