mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-23415 Server crash or Assertion `dec_length <= str_length' failed in Item_func_format::val_str_ascii
Problem:
The crash happened in FORMAT(double, dec>=31, 'de_DE').
The patch for MDEV-23118 (commit 0041dacc1b
)
did not take into account that String::set_real() has a limit of 31
(FLOATING_POINT_DECIMALS) fractional digits. So for the range of 31..38
digits, set_real() switches to use:
- my_fcvt() - decimal point notation, e.g. 1.9999999999
- my_gcvt() - scientific notation, e.g. 1e22
my_gcvt() returned a shorter string than Item_func_format::val_str_ascii()
expected to get after the my_fcvt() call, so it crashed on assert.
Solution:
We cannot extend set_real() to use the my_fcvt() mode for the range of
31..38 fractional digits, because set_real() is used in a lot of places
and such a change will break everything.
Introducing String::set_fcvt() which always prints using my_fcvt()
for the whole range of decimals 0..38, supported by the FORMAT() function.
This commit is contained in:
@ -517,6 +517,7 @@ public:
|
||||
|
||||
bool set_hex(ulonglong num);
|
||||
bool set_hex(const char *str, uint32 len);
|
||||
bool set_fcvt(double num, uint decimals);
|
||||
|
||||
bool copy(); // Alloc string if not alloced
|
||||
bool copy(const Binary_string &s); // Allocate new string
|
||||
@ -781,6 +782,11 @@ public:
|
||||
bool set(longlong num, CHARSET_INFO *cs) { return set_int(num, false, cs); }
|
||||
bool set(ulonglong num, CHARSET_INFO *cs) { return set_int((longlong)num, true, cs); }
|
||||
bool set_real(double num,uint decimals, CHARSET_INFO *cs);
|
||||
bool set_fcvt(double num, uint decimals)
|
||||
{
|
||||
set_charset(&my_charset_latin1);
|
||||
return Binary_string::set_fcvt(num, decimals);
|
||||
}
|
||||
|
||||
bool set_hex(ulonglong num)
|
||||
{
|
||||
|
Reference in New Issue
Block a user