diff options
author | Roman Nozdrin <roman.nozdrin@mariadb.com> | 2019-10-09 03:13:13 -0500 |
---|---|---|
committer | Roman Nozdrin <roman.nozdrin@mariadb.com> | 2019-10-31 02:26:04 -0500 |
commit | ad8266a5c2f087b8164bb2270108412608719daf (patch) | |
tree | e2bc1d47f9ff5e51b5795bb6c0f7d11e14c95ffd /sql/item_strfunc.cc | |
parent | 65358278859f3fd7704434b55fa2d414c570e8f6 (diff) | |
download | mariadb-git-ad8266a5c2f087b8164bb2270108412608719daf.tar.gz |
MDEV-20732 MDB now correctly estimates a length of the FORMAT() result for
doubles in scientific notation with a big integer part.
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r-- | sql/item_strfunc.cc | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index f571521b982..32f05a815db 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2666,10 +2666,17 @@ const int FORMAT_MAX_DECIMALS= 30; bool Item_func_format::fix_length_and_dec() { - uint32 char_length= args[0]->max_char_length(); - uint32 max_sep_count= (char_length / 3) + (decimals ? 1 : 0) + /*sign*/1; + uint32 char_length= args[0]->type_handler()->Item_decimal_notation_int_digits(args[0]); + uint dec= FORMAT_MAX_DECIMALS; + if (args[1]->const_item() && !args[1]->is_expensive()) + { + Longlong_hybrid tmp= args[1]->to_longlong_hybrid(); + if (!args[1]->null_value) + dec= tmp.to_uint(FORMAT_MAX_DECIMALS); + } + uint32 max_sep_count= (char_length / 3) + (dec ? 1 : 0) + /*sign*/1; collation.set(default_charset()); - fix_char_length(char_length + max_sep_count + decimals); + fix_char_length(char_length + max_sep_count + dec); if (arg_count == 3) locale= args[2]->basic_const_item() ? args[2]->locale_from_val_str() : NULL; else |