Loading mysql-test/r/func_str.result +6 −0 Original line number Diff line number Diff line Loading @@ -1011,3 +1011,9 @@ t 1000000 1 drop table t1; create table t1 (d decimal default null); insert into t1 values (null); select format(d, 2) from t1; format(d, 2) NULL drop table t1; mysql-test/t/func_str.test +10 −0 Original line number Diff line number Diff line Loading @@ -665,3 +665,13 @@ select rpad(i, 7, ' ') as t from t1; drop table t1; # End of 4.1 tests # # Bug #13361: SELECT FORMAT(<decimal field with null>, 2) crashes # create table t1 (d decimal default null); insert into t1 values (null); select format(d, 2) from t1; drop table t1; # End of 5.0 tests sql/item_strfunc.cc +2 −0 Original line number Diff line number Diff line Loading @@ -1733,6 +1733,8 @@ String *Item_func_format::val_str(String *str) { my_decimal dec_val, rnd_dec, *res; res= args[0]->val_decimal(&dec_val); if ((null_value=args[0]->null_value)) return 0; /* purecov: inspected */ my_decimal_round(E_DEC_FATAL_ERROR, res, decimals, false, &rnd_dec); my_decimal2string(E_DEC_FATAL_ERROR, &rnd_dec, 0, 0, 0, str); str_length= str->length(); Loading Loading
mysql-test/r/func_str.result +6 −0 Original line number Diff line number Diff line Loading @@ -1011,3 +1011,9 @@ t 1000000 1 drop table t1; create table t1 (d decimal default null); insert into t1 values (null); select format(d, 2) from t1; format(d, 2) NULL drop table t1;
mysql-test/t/func_str.test +10 −0 Original line number Diff line number Diff line Loading @@ -665,3 +665,13 @@ select rpad(i, 7, ' ') as t from t1; drop table t1; # End of 4.1 tests # # Bug #13361: SELECT FORMAT(<decimal field with null>, 2) crashes # create table t1 (d decimal default null); insert into t1 values (null); select format(d, 2) from t1; drop table t1; # End of 5.0 tests
sql/item_strfunc.cc +2 −0 Original line number Diff line number Diff line Loading @@ -1733,6 +1733,8 @@ String *Item_func_format::val_str(String *str) { my_decimal dec_val, rnd_dec, *res; res= args[0]->val_decimal(&dec_val); if ((null_value=args[0]->null_value)) return 0; /* purecov: inspected */ my_decimal_round(E_DEC_FATAL_ERROR, res, decimals, false, &rnd_dec); my_decimal2string(E_DEC_FATAL_ERROR, &rnd_dec, 0, 0, 0, str); str_length= str->length(); Loading