List:Commits« Previous MessageNext Message »
From:Tor Didriksen Date:November 15 2011 9:26am
Subject:bzr push into mysql-5.5 branch (tor.didriksen:3606 to 3607) Bug#13261955
View as plain text  
 3607 Tor Didriksen	2011-11-15
      Bug#13261955 TRUNCATE(DBL_MAX) RETURNS DBL_MAX RATHER THAN 'INF'
      
      my_double_round(DBL_MAX, -12, ....)
      should return 'inf' rather than DBL_MAX
      
      The problem is that floor(value/tmp) * tmp
      is inlined, and optimized away.
      
      The solution seems to be to prevent inlining by pre-computing value/tmp and
      storing it in a variable.
      
      No new test case: main.type_float fails without this patch.

    modified:
      sql/item_func.cc
 3606 chuck.bell@stripped	2011-11-11
      BUG#12929028: mysql_plugin : the --mysqld option is required, but not used
      
      This patch corrects a defect whereby the --mysqld, --my-print-defaults, 
      and --plugin-ini were required. These options are not required and the
      code has been fixed accordingly.

    modified:
      client/mysql_plugin.c
=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2011-07-18 09:21:14 +0000
+++ b/sql/item_func.cc	2011-11-15 09:01:29 +0000
@@ -2328,25 +2328,31 @@ double my_double_round(double value, lon
   /*
     tmp2 is here to avoid return the value with 80 bit precision
     This will fix that the test round(0.1,1) = round(0.1,1) is true
+    Tagging with volatile is no guarantee, it may still be optimized away...
   */
   volatile double tmp2;
 
   tmp=(abs_dec < array_elements(log_10) ?
        log_10[abs_dec] : pow(10.0,(double) abs_dec));
 
+  // Pre-compute these, to avoid optimizing away e.g. 'floor(v/tmp) * tmp'.
+  volatile double value_div_tmp= value / tmp;
+  volatile double value_mul_tmp= value * tmp;
+
   if (dec_negative && my_isinf(tmp))
-    tmp2= 0;
-  else if (!dec_negative && my_isinf(value * tmp))
+    tmp2= 0.0;
+  else if (!dec_negative && my_isinf(value_mul_tmp))
     tmp2= value;
   else if (truncate)
   {
-    if (value >= 0)
-      tmp2= dec < 0 ? floor(value/tmp)*tmp : floor(value*tmp)/tmp;
+    if (value >= 0.0)
+      tmp2= dec < 0 ? floor(value_div_tmp) * tmp : floor(value_mul_tmp) / tmp;
     else
-      tmp2= dec < 0 ? ceil(value/tmp)*tmp : ceil(value*tmp)/tmp;
+      tmp2= dec < 0 ? ceil(value_div_tmp) * tmp : ceil(value_mul_tmp) / tmp;
   }
   else
-    tmp2=dec < 0 ? rint(value/tmp)*tmp : rint(value*tmp)/tmp;
+    tmp2=dec < 0 ? rint(value_div_tmp) * tmp : rint(value_mul_tmp) / tmp;
+
   return tmp2;
 }
 

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.5 branch (tor.didriksen:3606 to 3607) Bug#13261955Tor Didriksen15 Nov