summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <serg@serg.mylan>2004-11-27 13:54:51 +0100
committerunknown <serg@serg.mylan>2004-11-27 13:54:51 +0100
commit6abe44badd8c02226cc7cc36b5c90e4e84e45171 (patch)
treeb4e00b99ad5188f38a09eb82ffbe067886c5a20e
parentfcee3e7ad6b194cce7ecada83eab2bf26d2de3ce (diff)
downloadmariadb-git-6abe44badd8c02226cc7cc36b5c90e4e84e45171.tar.gz
fix decimal2longlong too
mysql-test/r/rpl_start_stop_slave.result: results updated
-rw-r--r--mysql-test/r/rpl_start_stop_slave.result4
-rw-r--r--strings/decimal.c11
2 files changed, 9 insertions, 6 deletions
diff --git a/mysql-test/r/rpl_start_stop_slave.result b/mysql-test/r/rpl_start_stop_slave.result
index 1b4d87124d1..1fcb586d1fb 100644
--- a/mysql-test/r/rpl_start_stop_slave.result
+++ b/mysql-test/r/rpl_start_stop_slave.result
@@ -1,9 +1,9 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
stop slave;
create table t1(n int);
start slave;
diff --git a/strings/decimal.c b/strings/decimal.c
index 9b418dbe550..6e607aaa173 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -532,7 +532,7 @@ int decimal2longlong(decimal *from, longlong *to)
{
dec1 *buf=from->buf;
longlong x=0;
- int intg;
+ int intg, frac;
for (intg=from->intg; intg > 0; intg-=DIG_PER_DEC1)
{
@@ -540,11 +540,11 @@ int decimal2longlong(decimal *from, longlong *to)
/*
Attention: trick!
we're calculating -|from| instead of |from| here
- because |MIN_LONGLONG| > MAX_LONGLONG
+ because |LONGLONG_MIN| > LONGLONG_MAX
so we can convert -9223372036854775808 correctly
*/
x=x*DIG_BASE - *buf++;
- if (unlikely(x > y))
+ if (unlikely(y < (LONGLONG_MAX/DIG_BASE) || x > y))
{
*to= from->sign ? y : -y;
return E_DEC_OVERFLOW;
@@ -558,7 +558,10 @@ int decimal2longlong(decimal *from, longlong *to)
}
*to=from->sign ? x : -x;
- return from->frac ? E_DEC_TRUNCATED : E_DEC_OK;
+ for (frac=from->frac; unlikely(frac > 0); frac-=DIG_PER_DEC1)
+ if (*buf++)
+ return E_DEC_TRUNCATED;
+ return E_DEC_OK;
}
/*