List:Commits« Previous MessageNext Message »
From:Alexey Kopytov Date:February 15 2008 5:28pm
Subject:Re: bk commit into 5.1 tree (kaa:1.2659) BUG#31236
View as plain text  
Hi Serg,

Sergei Golubchik wrote:
> Hi!
> 
> On Feb 14, Alexey Kopytov wrote:
>> Below is the list of changes that have just been committed into a local
>> 5.1 repository of kaa.  When kaa does a push these changes
>> will be propagated to the main repository and, within 24 hours after the
>> push, to the public repository.
>> For information on how to access the public repository
>> see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
>>
>> ChangeSet@stripped, 2008-02-14 17:46:39+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.
>>
>>   configure.in@stripped, 2008-02-14 17:46:36+03:00, kaa@kaamos.(none) +2 -2
>>     Removed DONT_USE_FINITE, it is not used anywhere.
> 
> it's in my_global.h in my 5.1 tree. how comes ?
>  

Oops, because I forgot to remove it! The only use of it was:

#ifdef DONT_USE_FINITE    /* HPUX 11.x has is_finite() */
#undef HAVE_FINITE
#endif

I.e. "claim that we don't have finite() at all, without providing any 
replacements" (like is_finite() which is available on HPUX as the 
comments says).

Since the patch changes that to always define isfinite(), either as a 
native macro, or an alias to finite(), or a simple replacement, we don't 
need that define anymore. We also get rid of checks for HAVE_FINITE in 
the code.

Removed in the new patch.


>> 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-14 17:46:36 +03:00
>> @@ -1104,7 +1104,7 @@ double Item_func_plus::real_op()
>>    double value= args[0]->val_real() + args[1]->val_real();
>>    if ((null_value=args[0]->null_value || args[1]->null_value))
>>      return 0.0;
>> -  return value;
>> +  return fix_result(value);
>>  }
> 
> Is it the best approach ? I wonder perhaps the value could be fixed not
> in every item that does the calculations, but only when we need to do
> something with a result ? that is in double->string conversion. in
> isnull checks, in Field::store().
>   

Never passing an invalid value to another part of code looks more robust 
to me. Setting it to NULL right away means we won't even have to start a 
conversion, or any calculations in another function/operation. 
Currently, we assume everywhere that input floating point values are 
"sane", and only check if the output (the computed value) is finite.

Best regards,

-- 
Alexey Kopytov, Software Developer
MySQL AB, www.mysql.com

Are you MySQL certified?  www.mysql.com/certification
Thread
bk commit into 5.1 tree (kaa:1.2659) BUG#31236Alexey Kopytov14 Feb
  • Re: bk commit into 5.1 tree (kaa:1.2659) BUG#31236Sergei Golubchik15 Feb
    • Re: bk commit into 5.1 tree (kaa:1.2659) BUG#31236Alexey Kopytov15 Feb