summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorunknown <mhansson/martin@linux-st28.site>2008-01-17 18:22:55 +0100
committerunknown <mhansson/martin@linux-st28.site>2008-01-17 18:22:55 +0100
commit92141cd424b65559bb191f86dd1c2aedeb5e3254 (patch)
tree586f18d7908833a83c5dc560b66953787a263434 /strings
parent666efa1c43344a0b4dbe815e57333647d4d8f2b3 (diff)
parentf9440588f5bfbb4aef8934dbbda28f3e8872476f (diff)
downloadmariadb-git-92141cd424b65559bb191f86dd1c2aedeb5e3254.tar.gz
Merge linux-st28.site:/home/martin/mysql/src/bug33143/my50-bug33143-again
into linux-st28.site:/home/martin/mysql/src/bug33143/my51-bug33143 mysql-test/r/type_decimal.result: Auto merged sql/item_func.cc: Auto merged strings/decimal.c: Auto merged
Diffstat (limited to 'strings')
-rw-r--r--strings/decimal.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/strings/decimal.c b/strings/decimal.c
index f457014b2b1..0559dd97613 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -1601,9 +1601,21 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
x+=10;
*buf1=powers10[pos]*(x-y);
}
- if (frac0 < 0)
+ /*
+ In case we're rounding e.g. 1.5e9 to 2.0e9, the decimal_digit_t's inside
+ the buffer are as follows.
+
+ Before <1, 5e8>
+ After <2, 5e8>
+
+ Hence we need to set the 2nd field to 0.
+ The same holds if we round 1.5e-9 to 2e-9.
+ */
+ if (frac0 < frac1)
{
- dec1 *end=to->buf+intg0, *buf=buf1+1;
+ dec1 *buf= to->buf + ((scale == 0 && intg0 == 0) ? 1 : intg0 + frac0);
+ dec1 *end= to->buf + len;
+
while (buf < end)
*buf++=0;
}