diff options
author | unknown <hf@deer.(none)> | 2005-06-08 21:56:22 +0500 |
---|---|---|
committer | unknown <hf@deer.(none)> | 2005-06-08 21:56:22 +0500 |
commit | 1c5c678c139e2a2fbcda19a5d52ca35a07ecc7f9 (patch) | |
tree | b006d4d0d80d76393f851fb0be36971a276bab37 | |
parent | 60a5939f565077e4e57ec512139ca86aa0f06364 (diff) | |
download | mariadb-git-1c5c678c139e2a2fbcda19a5d52ca35a07ecc7f9.tar.gz |
Fix for bug #10896 (0.00 > -0.00)
mysql-test/r/type_newdecimal.result:
test result fixed
mysql-test/t/type_newdecimal.test:
test case added
sql/my_decimal.h:
we neede to check for zero here not to get -0.00
-rw-r--r-- | mysql-test/r/type_newdecimal.result | 11 | ||||
-rw-r--r-- | mysql-test/t/type_newdecimal.test | 11 | ||||
-rw-r--r-- | sql/my_decimal.h | 5 |
3 files changed, 27 insertions, 0 deletions
diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result index 09fbc6b8143..c0693d1585c 100644 --- a/mysql-test/r/type_newdecimal.result +++ b/mysql-test/r/type_newdecimal.result @@ -896,6 +896,8 @@ create table t1( d1 decimal(18) unsigned, d2 decimal(20) unsigned, d3 decimal (2 insert into t1 values(1,-1,-1); ERROR 22003: Out of range value adjusted for column 'd2' at row 1 drop table t1; +set sql_mode=''; +set @sav_dpi= @@div_precision_increment; set @@div_precision_increment=15; create table t1 (col1 int, col2 decimal(30,25), col3 numeric(30,25)); insert into t1 values (1,0.0123456789012345678912345,0.0123456789012345678912345); @@ -909,3 +911,12 @@ select 77777777/7777777; 77777777/7777777 10.000000900000090 drop table t1; +set div_precision_increment= @sav_dpi; +create table t1 (a decimal(4,2)); +insert into t1 values (0.00); +select * from t1 where a > -0.00; +a +select * from t1 where a = -0.00; +a +0.00 +drop table t1; diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test index 6bff6c22abc..d1d595285a2 100644 --- a/mysql-test/t/type_newdecimal.test +++ b/mysql-test/t/type_newdecimal.test @@ -934,10 +934,12 @@ create table t1( d1 decimal(18) unsigned, d2 decimal(20) unsigned, d3 decimal (2 --error 1264 insert into t1 values(1,-1,-1); drop table t1; +set sql_mode=''; # # Bug #8425 (insufficient precision of the division) # +set @sav_dpi= @@div_precision_increment; set @@div_precision_increment=15; create table t1 (col1 int, col2 decimal(30,25), col3 numeric(30,25)); insert into t1 values (1,0.0123456789012345678912345,0.0123456789012345678912345); @@ -945,4 +947,13 @@ select col2/9999999999 from t1 where col1=1; select 9999999999/col2 from t1 where col1=1; select 77777777/7777777; drop table t1; +set div_precision_increment= @sav_dpi; +# +# Bug #10896 (0.00 > -0.00) +# +create table t1 (a decimal(4,2)); +insert into t1 values (0.00); +select * from t1 where a > -0.00; +select * from t1 where a = -0.00; +drop table t1; diff --git a/sql/my_decimal.h b/sql/my_decimal.h index 27fd33cffbe..b65e6aedaa2 100644 --- a/sql/my_decimal.h +++ b/sql/my_decimal.h @@ -290,6 +290,11 @@ int int2my_decimal(uint mask, longlong i, my_bool unsigned_flag, my_decimal *d) inline void my_decimal_neg(decimal_t *arg) { + if (decimal_is_zero(arg)) + { + arg->sign= 0; + return; + } decimal_neg(arg); } |