MDEV-36334 test main.func_format fails on i386 on exabyte/petabyte mismatch
authorSergei Golubchik <serg@mariadb.org>
Wed, 2 Apr 2025 16:06:29 +0000 (18:06 +0200)
committerOtto Kekäläinen <otto@debian.org>
Wed, 23 Apr 2025 14:29:38 +0000 (07:29 -0700)
snprintf below uses %4.2f. values above 1023.99 MiB should be shown
as 1.00 GiB not as 1024.00 MiB

(cherry picked from commit e5574d8b94681755becead56fa67c95792f83668)

Origin: upstream, https://github.com/MariaDB/server/commit/e5574d8b94681755becead56fa67c95792f83668
Bug: https://jira.mariadb.org/browse/MDEV-36334

Gbp-Pq: Name MDEV-36334-test-main.func_format-fails-on-i386-on-exabyte.patch

mysql-test/main/func_format.result
sql/item_strfunc.cc

index eb0ee1d9644e5b3f96dadcb4b58bbb9b3edfccee..c1b7389bfdff578868359177824598ebafd1f8c6 100644 (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)
index ef958945c1128190e5f4e9e703449fe6b9ffc979..51b1cddb84f9e1e7989d37ce246a7ec5b90d0d11 100644 (file)
@@ -6155,7 +6155,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};