Skip to content

Commit

Permalink
str2decimal: don't return a negative zero
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Dec 5, 2016
1 parent 4a3acbc commit 02d153c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions mysql-test/r/type_decimal.result
Expand Up @@ -221,7 +221,6 @@ drop table t1;
create table t1 (a decimal(10,2) unsigned);
insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
Warnings:
Warning 1264 Out of range value for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 6
insert into t1 values ("-.1"),("+.1"),(".1");
Warnings:
Expand Down Expand Up @@ -280,7 +279,6 @@ drop table t1;
create table t1 (a decimal(10,2) zerofill);
insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
Warnings:
Warning 1264 Out of range value for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 6
insert into t1 values ("-.1"),("+.1"),(".1");
Warnings:
Expand Down Expand Up @@ -1012,6 +1010,9 @@ SELECT COLUMN_NAME, DATA_TYPE, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE
COLUMN_NAME DATA_TYPE COLUMN_TYPE
a decimal decimal(10,2)/*old*/
DROP TABLE t1dec102;
select cast('-0.0' as decimal(5,1)) < 0;
cast('-0.0' as decimal(5,1)) < 0
0
#
# End of 5.5 tests
#
5 changes: 5 additions & 0 deletions mysql-test/t/type_decimal.test
Expand Up @@ -604,6 +604,11 @@ SHOW COLUMNS FROM t1dec102;
SELECT COLUMN_NAME, DATA_TYPE, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='t1dec102';
DROP TABLE t1dec102;

#
# MDEV-10552 equality operation on cast of the value "-0.0" to decimal not working
#
select cast('-0.0' as decimal(5,1)) < 0;

--echo #
--echo # End of 5.5 tests
--echo #
2 changes: 0 additions & 2 deletions storage/tokudb/mysql-test/tokudb/r/type_decimal.result
Expand Up @@ -222,7 +222,6 @@ drop table t1;
create table t1 (a decimal(10,2) unsigned);
insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
Warnings:
Warning 1264 Out of range value for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 6
insert into t1 values ("-.1"),("+.1"),(".1");
Warnings:
Expand Down Expand Up @@ -281,7 +280,6 @@ drop table t1;
create table t1 (a decimal(10,2) zerofill);
insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
Warnings:
Warning 1264 Out of range value for column 'a' at row 2
Warning 1264 Out of range value for column 'a' at row 6
insert into t1 values ("-.1"),("+.1"),(".1");
Warnings:
Expand Down
2 changes: 2 additions & 0 deletions strings/decimal.c
Expand Up @@ -928,6 +928,8 @@ internal_str2dec(const char *from, decimal_t *to, char **end, my_bool fixed)
error= decimal_shift(to, (int) exponent);
}
}
if (to->sign && decimal_is_zero(to))
to->sign= 0;
return error;

fatal_error:
Expand Down

0 comments on commit 02d153c

Please sign in to comment.