summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorunknown <hf@deer.(none)>2005-07-12 14:17:59 +0500
committerunknown <hf@deer.(none)>2005-07-12 14:17:59 +0500
commit66d633b8b3a1d2fc83f1a99e75051011bb70b5e9 (patch)
tree8c809e2e67eaf131691de4db9c69077216ff7111 /strings
parent2508b29e7c0833316934ed3bbecd74c5983bf388 (diff)
downloadmariadb-git-66d633b8b3a1d2fc83f1a99e75051011bb70b5e9.tar.gz
Fix for bug #11557 (Error during rounding of the DEFAULT values)
mysql-test/r/type_newdecimal.result: test result fixed mysql-test/t/type_newdecimal.test: test case added strings/decimal.c: Code to check 999.9 -> 1000 case should work always
Diffstat (limited to 'strings')
-rw-r--r--strings/decimal.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/strings/decimal.c b/strings/decimal.c
index 76e62080ba0..1d75502f0da 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -1443,6 +1443,7 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
intg1=ROUND_UP(from->intg +
(((intg0 + frac0)>0) && (from->buf[0] == DIG_MAX)));
dec1 *buf0=from->buf, *buf1=to->buf, x, y, carry=0;
+ int first_dig;
sanity(to);
@@ -1578,14 +1579,6 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
*buf1=1;
to->intg++;
}
- else
- {
- /* Here we check 999.9 -> 1000 case when we need to increase intg */
- int first_dig= to->intg % DIG_PER_DEC1;
- /* first_dig==0 should be handled above in the 'if' */
- if (first_dig && (*buf1 >= powers10[first_dig]))
- to->intg++;
- }
}
else
{
@@ -1606,6 +1599,12 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
}
}
}
+
+ /* Here we check 999.9 -> 1000 case when we need to increase intg */
+ first_dig= to->intg % DIG_PER_DEC1;
+ if (first_dig && (*buf1 >= powers10[first_dig]))
+ to->intg++;
+
if (scale<0)
scale=0;