Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions mysql-test/main/type_newdecimal.result
Original file line number Diff line number Diff line change
Expand Up @@ -3053,4 +3053,16 @@ truncate 2
select '12185184186.000000000000000000000000000024692343000000000000000000000000000000000002' as 'exact result';
exact result
12185184186.000000000000000000000000000024692343000000000000000000000000000000000002
#
# MDEV-39744: Assertion `buf != end` failed in `decimal_mul`
#
SET @old_prec_incr= @@SESSION.div_precision_increment;
SET @@SESSION.div_precision_increment=0;
SELECT ((273 / 941) * (-299 / 450)) as x;
x
0
SELECT (-299 / 450) AS neg_div;
neg_div
0
SET @@SESSION.div_precision_increment=@old_prec_incr;
# End of 10.11 tests
12 changes: 12 additions & 0 deletions mysql-test/main/type_newdecimal.test
Original file line number Diff line number Diff line change
Expand Up @@ -2105,4 +2105,16 @@ select 12345678 * 987.000000000000000000000000000000000002 as 'truncate 1';
select 12345678.000000000000000000000000000000000001 * 987 as 'truncate 2';
select '12185184186.000000000000000000000000000024692343000000000000000000000000000000000002' as 'exact result';

--echo #
--echo # MDEV-39744: Assertion `buf != end` failed in `decimal_mul`
--echo #

SET @old_prec_incr= @@SESSION.div_precision_increment;

SET @@SESSION.div_precision_increment=0;
SELECT ((273 / 941) * (-299 / 450)) as x;
SELECT (-299 / 450) AS neg_div;

SET @@SESSION.div_precision_increment=@old_prec_incr;

--echo # End of 10.11 tests
5 changes: 5 additions & 0 deletions strings/decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2314,6 +2314,11 @@ static int do_div_mod(const decimal_t *from1, const decimal_t *from2,
to->sign=from1->sign != from2->sign;
to->intg=intg0*DIG_PER_DEC1;
to->frac=frac0*DIG_PER_DEC1;
if (unlikely(frac0==0 && intg0==0))
{
decimal_make_zero(to);
return E_DEC_OK;
}
}
buf0=to->buf;
stop0=buf0+intg0+frac0;
Expand Down