Below is the list of changes that have just been committed into a local
5.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.1941 05/06/15 19:53:40 hf@deer.(none) +3 -0
Fix for bug #10632 (CEILING returns wrong result)
strings/decimal.c
1.53 05/06/15 19:52:42 hf@deer.(none) +25 -4
handling of round_digit changed - we have to check all the digits after
the point if round_digit is 0
mysql-test/t/func_math.test
1.19 05/06/15 19:52:41 hf@deer.(none) +7 -0
test case added
mysql-test/r/func_math.result
1.27 05/06/15 19:52:41 hf@deer.(none) +6 -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-5.0.10632
--- 1.26/mysql-test/r/func_math.result Thu Jun 9 15:26:47 2005
+++ 1.27/mysql-test/r/func_math.result Wed Jun 15 19:52:41 2005
@@ -146,3 +146,9 @@
select round(150, 2);
round(150, 2)
150.00
+select ceil(0.09);
+ceil(0.09)
+1
+select ceil(0.000000000000000009);
+ceil(0.000000000000000009)
+1
--- 1.18/mysql-test/t/func_math.test Thu Jun 9 15:26:47 2005
+++ 1.19/mysql-test/t/func_math.test Wed Jun 15 19:52:41 2005
@@ -84,3 +84,10 @@
# Bug #10083 (round doesn't increase decimals)
#
select round(150, 2);
+
+#
+# Bug @10632 (Ceiling function returns wrong answer)
+#
+select ceil(0.09);
+select ceil(0.000000000000000009);
+
--- 1.52/strings/decimal.c Thu Jun 9 12:42:55 2005
+++ 1.53/strings/decimal.c Wed Jun 15 19:52:42 2005
@@ -1490,11 +1490,31 @@
buf1+=intg0+frac0-1;
if (scale == frac0*DIG_PER_DEC1)
{
+ int do_inc= FALSE;
DBUG_ASSERT(frac0+intg0 >= 0);
- x=buf0[1]/DIG_MASK;
- if (x > round_digit ||
- (round_digit == 5 && x == 5 && (mode == HALF_UP ||
- (frac0+intg0 > 0 && *buf0 & 1))))
+ switch (round_digit)
+ {
+ case 0:
+ {
+ dec1 *p0= buf0 + (frac1-frac0);
+ for (; p0 > buf0; p0--)
+ if (*p0)
+ {
+ do_inc= TRUE;
+ break;
+ };
+ break;
+ }
+ case 5:
+ {
+ x= buf0[1]/DIG_MASK;
+ do_inc= (x>5) || ((x == 5) &&
+ (mode == HALF_UP || (frac0+intg0 > 0 && *buf0 &
1)));
+ break;
+ };
+ default:;
+ };
+ if (do_inc)
{
if (frac0+intg0>0)
(*buf1)++;
@@ -1509,6 +1529,7 @@
}
else
{
+ /* TODO - fix this code as it won't work for CEILING mode */
int pos=frac0*DIG_PER_DEC1-scale-1;
DBUG_ASSERT(frac0+intg0 > 0);
x=*buf1 / powers10[pos];
| Thread |
|---|
| • bk commit into 5.0 tree (hf:1.1941) BUG#10632 | holyfoot | 15 Jun |