Skip to content

Commit 02d153c

Browse files
committed
str2decimal: don't return a negative zero
1 parent 4a3acbc commit 02d153c

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

mysql-test/r/type_decimal.result

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ drop table t1;
221221
create table t1 (a decimal(10,2) unsigned);
222222
insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
223223
Warnings:
224-
Warning 1264 Out of range value for column 'a' at row 2
225224
Warning 1264 Out of range value for column 'a' at row 6
226225
insert into t1 values ("-.1"),("+.1"),(".1");
227226
Warnings:
@@ -280,7 +279,6 @@ drop table t1;
280279
create table t1 (a decimal(10,2) zerofill);
281280
insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
282281
Warnings:
283-
Warning 1264 Out of range value for column 'a' at row 2
284282
Warning 1264 Out of range value for column 'a' at row 6
285283
insert into t1 values ("-.1"),("+.1"),(".1");
286284
Warnings:
@@ -1012,6 +1010,9 @@ SELECT COLUMN_NAME, DATA_TYPE, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE
10121010
COLUMN_NAME DATA_TYPE COLUMN_TYPE
10131011
a decimal decimal(10,2)/*old*/
10141012
DROP TABLE t1dec102;
1013+
select cast('-0.0' as decimal(5,1)) < 0;
1014+
cast('-0.0' as decimal(5,1)) < 0
1015+
0
10151016
#
10161017
# End of 5.5 tests
10171018
#

mysql-test/t/type_decimal.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,11 @@ SHOW COLUMNS FROM t1dec102;
604604
SELECT COLUMN_NAME, DATA_TYPE, COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='t1dec102';
605605
DROP TABLE t1dec102;
606606

607+
#
608+
# MDEV-10552 equality operation on cast of the value "-0.0" to decimal not working
609+
#
610+
select cast('-0.0' as decimal(5,1)) < 0;
611+
607612
--echo #
608613
--echo # End of 5.5 tests
609614
--echo #

storage/tokudb/mysql-test/tokudb/r/type_decimal.result

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ drop table t1;
222222
create table t1 (a decimal(10,2) unsigned);
223223
insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
224224
Warnings:
225-
Warning 1264 Out of range value for column 'a' at row 2
226225
Warning 1264 Out of range value for column 'a' at row 6
227226
insert into t1 values ("-.1"),("+.1"),(".1");
228227
Warnings:
@@ -281,7 +280,6 @@ drop table t1;
281280
create table t1 (a decimal(10,2) zerofill);
282281
insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
283282
Warnings:
284-
Warning 1264 Out of range value for column 'a' at row 2
285283
Warning 1264 Out of range value for column 'a' at row 6
286284
insert into t1 values ("-.1"),("+.1"),(".1");
287285
Warnings:

strings/decimal.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,8 @@ internal_str2dec(const char *from, decimal_t *to, char **end, my_bool fixed)
928928
error= decimal_shift(to, (int) exponent);
929929
}
930930
}
931+
if (to->sign && decimal_is_zero(to))
932+
to->sign= 0;
931933
return error;
932934

933935
fatal_error:

0 commit comments

Comments
 (0)