Hi!
On Feb 15, Alexey Kopytov wrote:
> ChangeSet@stripped, 2008-02-15 19:50:19+03:00, kaa@kaamos.(none) +9 -0
> 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.
>
> diff -Nrup a/sql/item_func.cc b/sql/item_func.cc
> --- a/sql/item_func.cc 2008-01-19 20:59:07 +03:00
> +++ b/sql/item_func.cc 2008-02-15 19:50:18 +03:00
> @@ -1710,9 +1710,9 @@ double Item_func_atan::val_real()
> double val2= args[1]->val_real();
> if ((null_value=args[1]->null_value))
> return 0.0;
> - return fix_result(atan2(value,val2));
> + return atan2(value,val2);
atan2 is always defined ? even if val2==0 ?
> }
> - return fix_result(atan(value));
> + return atan(value);
> }
>
> double Item_func_cos::val_real()
> diff -Nrup a/sql/item_func.h b/sql/item_func.h
> --- a/sql/item_func.h 2007-12-13 14:57:03 +03:00
> +++ b/sql/item_func.h 2008-02-15 19:50:18 +03:00
> @@ -192,6 +192,14 @@ public:
> void * arg, traverse_order order);
> bool is_expensive_processor(uchar *arg);
> virtual bool is_expensive() { return 0; }
> + inline double fix_result(double value)
> + {
> + /* The following should be safe, even if we compare doubles */
the command makes no sense
> + if (isfinite(value))
> + return value;
> + null_value=1;
> + return 0.0;
> + }
> };
>
> diff -Nrup a/sql/matherr.c b/sql/matherr.c
> --- a/sql/matherr.c 2006-12-30 23:02:07 +03:00
> +++ /dev/null Wed Dec 31 16:00:00 196900
Why did you delete it ?
(won't default matherr print an error to stderr ?)
Regards / Mit vielen Grüssen,
Sergei
--
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Sergei Golubchik <serg@stripped>
/ /|_/ / // /\ \/ /_/ / /__ Principal Software Developer/Server Architect
/_/ /_/\_, /___/\___\_\___/ MySQL GmbH, Dachauer Str. 37, D-80335 München
<___/ Geschäftsführer: Kaj Arnö - HRB
München 162140