MDEV-36334 test main.func_format fails on i386 on exabyte/petabyte mismatch

snprintf below uses %4.2f. values above 1023.99 MiB should be shown
as 1.00 GiB not as 1024.00 MiB
This commit is contained in:
Sergei Golubchik 2025-04-02 18:06:29 +02:00
parent 29823f3b96
commit e5574d8b94
2 changed files with 8 additions and 5 deletions

View File

@ -248,7 +248,7 @@ format_bytes(1024 * 1024 - 200)
SELECT format_bytes(1024 * 1024 - 1);
format_bytes(1024 * 1024 - 1)
1024.00 KiB
1.00 MiB
SELECT format_bytes(1024 * 1024);
format_bytes(1024 * 1024)
@ -264,7 +264,7 @@ format_bytes(1024 * 1024 + 200)
SELECT format_bytes(1024 * 1024 * 1024 - 1);
format_bytes(1024 * 1024 * 1024 - 1)
1024.00 MiB
1.00 GiB
SELECT format_bytes(1024 * 1024 * 1024);
format_bytes(1024 * 1024 * 1024)
@ -276,7 +276,7 @@ format_bytes(1024 * 1024 * 1024 + 1)
SELECT format_bytes(1024 * 1024 * 1024 * 1024 - 1);
format_bytes(1024 * 1024 * 1024 * 1024 - 1)
1024.00 GiB
1.00 TiB
SELECT format_bytes(1024 * 1024 * 1024 * 1024);
format_bytes(1024 * 1024 * 1024 * 1024)
@ -288,7 +288,7 @@ format_bytes(1024 * 1024 * 1024 * 1024 + 1)
SELECT format_bytes(1024 * 1024 * 1024 * 1024 * 1024 - 1);
format_bytes(1024 * 1024 * 1024 * 1024 * 1024 - 1)
1024.00 TiB
1.00 PiB
SELECT format_bytes(1024 * 1024 * 1024 * 1024 * 1024);
format_bytes(1024 * 1024 * 1024 * 1024 * 1024)

View File

@ -6161,7 +6161,10 @@ String *Item_func_format_bytes::val_str_ascii(String *)
if (null_value)
return 0;
double bytes_abs= fabs(bytes);
/*
snprintf below uses %4.2f, so 1023.99 MiB should be shown as 1.00 GiB
*/
double bytes_abs= fabs(bytes)/1023.995*1024;
constexpr uint64_t kib{1024};
constexpr uint64_t mib{1024 * kib};