MDEV-26691 SFORMAT: Pass down FLOAT as FLOAT, without upcast to DOUBLE

This commit is contained in:
Sergei Golubchik 2021-10-09 15:35:22 +02:00
parent 284ed64336
commit 6a7c10de92
3 changed files with 16 additions and 1 deletions

View file

@ -449,3 +449,9 @@ sformat("={:d}=", ?)
NULL
Warnings:
Warning 4183 SFORMAT error: invalid type specifier
#
# MDEV-26691 SFORMAT: Pass down FLOAT as FLOAT, without upcast to DOUBLE
#
select sformat('{}', cast(1.1 as float));
sformat('{}', cast(1.1 as float))
1.1

View file

@ -207,3 +207,9 @@ echo #;
prepare s from 'select sformat("={:d}=", ?)';
execute s using 100;
execute s using 'abc';
echo #;
echo # MDEV-26691 SFORMAT: Pass down FLOAT as FLOAT, without upcast to DOUBLE;
echo #;
select sformat('{}', cast(1.1 as float));

View file

@ -1393,7 +1393,10 @@ String *Item_func_sformat::val_str(String *res)
break;
case DECIMAL_RESULT: // TODO
case REAL_RESULT:
vargs[carg-1]= fmt::detail::make_arg<ctx>(args[carg]->val_real());
if (args[carg]->field_type() == MYSQL_TYPE_FLOAT)
vargs[carg-1]= fmt::detail::make_arg<ctx>((float)args[carg]->val_real());
else
vargs[carg-1]= fmt::detail::make_arg<ctx>(args[carg]->val_real());
break;
case STRING_RESULT:
if (!(parg= args[carg]->val_str(&val_arg[carg-1])))