diff options
author | holyfoot/hf@hfmain.(none) <> | 2007-05-21 22:24:31 +0500 |
---|---|---|
committer | holyfoot/hf@hfmain.(none) <> | 2007-05-21 22:24:31 +0500 |
commit | 8fcd446b20ecc961bb8c6827835d6e97f6f647f7 (patch) | |
tree | e6159e899d8caf84076c1ce4f026423779d94741 | |
parent | c4d3178eca6f9ee91e5f251b8bc40363525f643d (diff) | |
parent | 84a572aabf092a799a81e065d79caa88fdf46ef3 (diff) | |
download | mariadb-git-8fcd446b20ecc961bb8c6827835d6e97f6f647f7.tar.gz |
Merge mysql.com:/home/hf/work/27984/my50-27984
into mysql.com:/home/hf/work/27984/my51-27984
-rw-r--r-- | mysql-test/r/type_newdecimal.result | 3 | ||||
-rw-r--r-- | mysql-test/t/type_newdecimal.test | 5 | ||||
-rw-r--r-- | strings/decimal.c | 3 |
3 files changed, 10 insertions, 1 deletions
diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result index 855c452cb21..8405ec9782c 100644 --- a/mysql-test/r/type_newdecimal.result +++ b/mysql-test/r/type_newdecimal.result @@ -1475,6 +1475,9 @@ Error 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1 Error 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1 Error 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1 Error 1264 Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1 +SELECT 1.000000000000 * 99.999999999998 / 100 a,1.000000000000 * (99.999999999998 / 100) b; +a b +0.9999999999999800000000000000 0.9999999999999800000000000000 End of 5.0 tests select cast(143.481 as decimal(4,1)); cast(143.481 as decimal(4,1)) diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test index 0a52bdaa8e6..566682d8e58 100644 --- a/mysql-test/t/type_newdecimal.test +++ b/mysql-test/t/type_newdecimal.test @@ -1159,6 +1159,11 @@ select cast(a as DECIMAL(3,2)), count(*) UNION select 12.1234 ) t group by 1; +# +# Bug #27984 Long Decimal Maths produces truncated results +# + +SELECT 1.000000000000 * 99.999999999998 / 100 a,1.000000000000 * (99.999999999998 / 100) b; --echo End of 5.0 tests # diff --git a/strings/decimal.c b/strings/decimal.c index 0768c8cd4ca..09d535f3f22 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -1523,9 +1523,10 @@ decimal_round(decimal_t *from, decimal_t *to, int scale, dec1 *p0= buf0+intg0+max(frac1, frac0); dec1 *p1= buf1+intg1+max(frac1, frac0); - to->buf[0]= 0; while (buf0 < p0) *(--p1) = *(--p0); + if (unlikely(intg1 > intg0)) + to->buf[0]= 0; intg0= intg1; buf0=to->buf; |