Commit d2e80802 authored by Sergei Golubchik's avatar Sergei Golubchik

fixes for decimal type

parent 7989c62b
...@@ -1988,3 +1988,9 @@ SELECT d1 * d2 FROM t1; ...@@ -1988,3 +1988,9 @@ SELECT d1 * d2 FROM t1;
d1 * d2 d1 * d2
0 0
DROP TABLE t1; DROP TABLE t1;
select 0.000000000000000000000000000000000000000000000000001 mod 1;
0.000000000000000000000000000000000000000000000000001 mod 1
0.000000000000000000000000000000
select 0.0000000001 mod 1;
0.0000000001 mod 1
0.0000000001
...@@ -1570,3 +1570,12 @@ SELECT d1 * d2 FROM t1; ...@@ -1570,3 +1570,12 @@ SELECT d1 * d2 FROM t1;
DROP TABLE t1; DROP TABLE t1;
#
# Test for Bug#18469276: MOD FOR SMALL DECIMALS FAILS
#
select 0.000000000000000000000000000000000000000000000000001 mod 1;
#
# incorrect result
#
select 0.0000000001 mod 1;
...@@ -127,7 +127,6 @@ typedef longlong dec2; ...@@ -127,7 +127,6 @@ typedef longlong dec2;
#define DIG_BASE 1000000000 #define DIG_BASE 1000000000
#define DIG_MAX (DIG_BASE-1) #define DIG_MAX (DIG_BASE-1)
#define DIG_BASE2 ((dec2)DIG_BASE * (dec2)DIG_BASE) #define DIG_BASE2 ((dec2)DIG_BASE * (dec2)DIG_BASE)
#define ROUND_UP(X) (((X)+DIG_PER_DEC1-1)/DIG_PER_DEC1)
static const dec1 powers10[DIG_PER_DEC1+1]={ static const dec1 powers10[DIG_PER_DEC1+1]={
1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000}; 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000};
static const int dig2bytes[DIG_PER_DEC1+1]={0, 1, 1, 2, 2, 3, 3, 4, 4, 4}; static const int dig2bytes[DIG_PER_DEC1+1]={0, 1, 1, 2, 2, 3, 3, 4, 4, 4};
...@@ -136,6 +135,11 @@ static const dec1 frac_max[DIG_PER_DEC1-1]={ ...@@ -136,6 +135,11 @@ static const dec1 frac_max[DIG_PER_DEC1-1]={
999900000, 999990000, 999999000, 999900000, 999990000, 999999000,
999999900, 999999990 }; 999999900, 999999990 };
static inline int ROUND_UP(int x)
{
return (x + (x > 0 ? 1 : -1) * (DIG_PER_DEC1 - 1)) / DIG_PER_DEC1;
}
#ifdef HAVE_valgrind #ifdef HAVE_valgrind
#define sanity(d) DBUG_ASSERT((d)->len > 0) #define sanity(d) DBUG_ASSERT((d)->len > 0)
#else #else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment