Vec_ToText was underestimating max_length of the result

switch to a more predictable, shorter, and more correct output
that is, print as many significant digits as necessary.
but not more (they'd be just zeros) and not less (it'd lose precision)
This commit is contained in:
Sergei Golubchik 2024-10-15 19:05:18 +02:00
commit 88119addff
7 changed files with 41 additions and 31 deletions

View file

@ -97,7 +97,11 @@ String *Item_func_vec_totext::val_str_ascii(String *str)
else if (std::isnan(val))
str->append(STRING_WITH_LEN("NaN"));
else
str->append_float(val, FLT_DIG);
{
char buf[MAX_FLOAT_STR_LENGTH+1];
size_t l= my_gcvt(val, MY_GCVT_ARG_FLOAT, MAX_FLOAT_STR_LENGTH, buf, 0);
str->append(buf, l);
}
ptr+= 4;
if (r1->length() - i > 4)