Bug#57810 case/when/then : Assertion failed: length || !scale
ASSERT happens due to improper calculation of the max_length in Item_func_div object, if dividend has max_length == 0 then Item_func_div::max_length is set to 0 under some circumstances. The fix: If decimals == NOT_FIXED_DEC then set Item_func_div::max_length to max possible DOUBLE length value.
This commit is contained in:
parent
8b0f0a9723
commit
b69b46c775
@ -498,4 +498,17 @@ SELECT -9223372036854775808 MOD -1;
|
|||||||
SELECT -9223372036854775808999 MOD -1;
|
SELECT -9223372036854775808999 MOD -1;
|
||||||
-9223372036854775808999 MOD -1
|
-9223372036854775808999 MOD -1
|
||||||
0
|
0
|
||||||
|
#
|
||||||
|
# Bug#57810 case/when/then : Assertion failed: length || !scale
|
||||||
|
#
|
||||||
|
SELECT CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1)) END;
|
||||||
|
CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1)) END
|
||||||
|
NULL
|
||||||
|
CREATE TABLE t1 SELECT CAST((CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1)) END) AS CHAR) as C;
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`C` varchar(23) DEFAULT NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||||
|
DROP TABLE t1;
|
||||||
End of 5.1 tests
|
End of 5.1 tests
|
||||||
|
@ -315,4 +315,13 @@ SELECT -9223372036854775808 DIV -1;
|
|||||||
SELECT -9223372036854775808 MOD -1;
|
SELECT -9223372036854775808 MOD -1;
|
||||||
SELECT -9223372036854775808999 MOD -1;
|
SELECT -9223372036854775808999 MOD -1;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # Bug#57810 case/when/then : Assertion failed: length || !scale
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
SELECT CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1)) END;
|
||||||
|
CREATE TABLE t1 SELECT CAST((CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1)) END) AS CHAR) as C;
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
DROP TABLE t1;
|
||||||
|
|
||||||
--echo End of 5.1 tests
|
--echo End of 5.1 tests
|
||||||
|
@ -1329,9 +1329,14 @@ void Item_func_div::fix_length_and_dec()
|
|||||||
{
|
{
|
||||||
decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
|
decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
|
||||||
set_if_smaller(decimals, NOT_FIXED_DEC);
|
set_if_smaller(decimals, NOT_FIXED_DEC);
|
||||||
max_length=args[0]->max_length - args[0]->decimals + decimals;
|
|
||||||
uint tmp=float_length(decimals);
|
uint tmp=float_length(decimals);
|
||||||
set_if_smaller(max_length,tmp);
|
if (decimals == NOT_FIXED_DEC)
|
||||||
|
max_length= tmp;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
max_length=args[0]->max_length - args[0]->decimals + decimals;
|
||||||
|
set_if_smaller(max_length,tmp);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case INT_RESULT:
|
case INT_RESULT:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user