summaryrefslogtreecommitdiff
path: root/strings/decimal.c
diff options
context:
space:
mode:
authorunknown <holyfoot/hf@mysql.com/hfmain.(none)>2007-05-16 10:12:49 +0500
committerunknown <holyfoot/hf@mysql.com/hfmain.(none)>2007-05-16 10:12:49 +0500
commit1e33cfb36a84b477a468dbcfc1ccc3035a9efb81 (patch)
treecc5b5bde02ab2b13971ee22d8bd647a5f35776fa /strings/decimal.c
parentd886ea8fb66c10e58029bf7c010a1a2a085ad23d (diff)
downloadmariadb-git-1e33cfb36a84b477a468dbcfc1ccc3035a9efb81.tar.gz
bug #8663 cant use bigint unsigned as input to cast
in the case of the overflow in the decimal->integer conversion we didn't return the proper boundary value, but just the result of the conversion we calculated on the moment of the error mysql-test/r/bigint.result: bug #8663 cant use bigint unsigned as input to cast test result fixed mysql-test/t/bigint.test: bug #8663 cant use bigint unsigned as input to cast test case strings/decimal.c: bug #8663 cant use bigint unsigned as input to cast decimal->int conversion fixed to return proper boundary value in the case of overflow
Diffstat (limited to 'strings/decimal.c')
-rw-r--r--strings/decimal.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/strings/decimal.c b/strings/decimal.c
index 65db68b1b59..1ae75167794 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -1083,7 +1083,11 @@ int decimal2longlong(decimal_t *from, longlong *to)
x=x*DIG_BASE - *buf++;
if (unlikely(y < (LONGLONG_MIN/DIG_BASE) || x > y))
{
- *to= from->sign ? y : -y;
+ /*
+ the decimal is bigger than any possible integer
+ return border integer depending on the sign
+ */
+ *to= from->sign ? LONGLONG_MIN : LONGLONG_MAX;
return E_DEC_OVERFLOW;
}
}