Below is the list of changes that have just been committed into a local
4.0 repository of hf. When hf 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
1.2086 05/03/17 00:42:39 hf@deer.(none) +5 -0
Fix for bug #9060 (FORMAT returns incorrect result)
we need proper rounding there
sql/mysql_priv.h
1.232 05/03/17 00:42:24 hf@deer.(none) +1 -0
my_double_round interface
sql/item_strfunc.cc
1.86 05/03/17 00:42:24 hf@deer.(none) +2 -1
my_double_round used
sql/item_func.cc
1.112 05/03/17 00:42:24 hf@deer.(none) +13 -6
my_double_round implementation added
mysql-test/t/func_math.test
1.12 05/03/17 00:42:24 hf@deer.(none) +5 -0
test case added
mysql-test/r/func_math.result
1.19 05/03/17 00:42:24 hf@deer.(none) +3 -0
test result fixed
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: hf
# Host: deer.(none)
# Root: /home/hf/work/mysql-4.0.9060
--- 1.111/sql/item_func.cc Tue Aug 24 18:29:05 2004
+++ 1.112/sql/item_func.cc Thu Mar 17 00:42:24 2005
@@ -688,20 +688,16 @@
}
}
-double Item_func_round::val()
+double my_double_round(double value, int dec, bool truncate)
{
- double value=args[0]->val();
- int dec=(int) args[1]->val_int();
- uint abs_dec=abs(dec);
double tmp;
+ uint abs_dec=abs(dec);
/*
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
*/
volatile double tmp2;
- if ((null_value=args[0]->null_value || args[1]->null_value))
- return 0.0;
tmp=(abs_dec < array_elements(log_10) ?
log_10[abs_dec] : pow(10.0,(double) abs_dec));
@@ -715,6 +711,17 @@
else
tmp2=dec < 0 ? rint(value/tmp)*tmp : rint(value*tmp)/tmp;
return tmp2;
+}
+
+double Item_func_round::val()
+{
+ double value=args[0]->val();
+ int dec=(int) args[1]->val_int();
+
+ if ((null_value=args[0]->null_value || args[1]->null_value))
+ return 0.0;
+
+ return my_double_round(value, dec, truncate);
}
--- 1.85/sql/item_strfunc.cc Wed Mar 9 12:13:35 2005
+++ 1.86/sql/item_strfunc.cc Thu Mar 17 00:42:24 2005
@@ -1470,7 +1470,8 @@
int diff;
uint dec;
if ((null_value=args[0]->null_value))
- return 0; /* purecov: inspected */
+ return 0; /* purecov: insected */
+ nr= my_double_round(nr, decimals, FALSE);
dec= decimals ? decimals+1 : 0;
str->set(nr,decimals);
#ifdef HAVE_ISNAN
--- 1.231/sql/mysql_priv.h Thu Mar 3 22:51:26 2005
+++ 1.232/sql/mysql_priv.h Thu Mar 17 00:42:24 2005
@@ -831,6 +831,7 @@
SQL_SELECT *select, ha_rows special,ha_rows max_rows,
ha_rows *examined_rows);
void change_double_for_sort(double nr,byte *to);
+double my_double_round(double value, int dec, bool truncate);
int get_quick_record(SQL_SELECT *select);
int calc_weekday(long daynr,bool sunday_first_day_of_week);
uint calc_week(TIME *l_time, uint week_behaviour, uint *year);
--- 1.18/mysql-test/r/func_math.result Wed Aug 11 16:11:56 2004
+++ 1.19/mysql-test/r/func_math.result Thu Mar 17 00:42:24 2005
@@ -59,3 +59,6 @@
SELECT ASIN(1.2-0.2);
ASIN(1.2-0.2)
1.5707963267949
+select format(4.55, 1), format(4.551, 1);
+format(4.55, 1) format(4.551, 1)
+4.6 4.6
--- 1.11/mysql-test/t/func_math.test Wed Aug 11 16:11:56 2004
+++ 1.12/mysql-test/t/func_math.test Thu Mar 17 00:42:24 2005
@@ -37,3 +37,8 @@
#select floor(log(4)/log(2));
#select floor(log(8)/log(2));
#select floor(log(16)/log(2));
+
+#
+# Bug #9060 (format returns incorrect result)
+#
+select format(4.55, 1), format(4.551, 1);
| Thread |
|---|
| • bk commit into 4.0 tree (hf:1.2086) BUG#9060 | holyfoot | 16 Mar |