Bug #96783 format_bytes is now a native function
Submitted: 6 Sep 2019 22:08 Modified: 9 Sep 2019 15:52
Reporter: Morgan Tocker Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:8.0 OS:Any
Assigned to: Jon Stephens CPU Architecture:Any

[6 Sep 2019 22:08] Morgan Tocker
Description:
I tried the pfs example from this manual page:
https://dev.mysql.com/doc/refman/8.0/en/memory-use.html

It produced a warning.

How to repeat:
mysql [localhost:8016] {msandbox} ((none)) >  SELECT SUBSTRING_INDEX(event_name,'/',2) AS code_area, sys.format_bytes(SUM(current_alloc)) AS current_alloc FROM sys.x$memory_global_by_current_bytes GROUP BY SUBSTRING_INDEX(event_name,'/',2) ORDER BY SUM(current_alloc) DESC;
+---------------------------+---------------+
| code_area                 | current_alloc |
+---------------------------+---------------+
| memory/performance_schema | 266.76 MiB    |
| memory/innodb             | 185.10 MiB    |
| memory/mysys              | 8.57 MiB      |
| memory/sql                | 3.49 MiB      |
| memory/temptable          | 1.00 MiB      |
| memory/mysqld_openssl     | 130.29 KiB    |
| memory/mysqlx             | 3.44 KiB      |
| memory/myisam             | 696 bytes     |
| memory/vio                | 656 bytes     |
| memory/csv                | 88 bytes      |
| memory/blackhole          | 88 bytes      |
+---------------------------+---------------+
11 rows in set, 1 warning (0.03 sec)

mysql [localhost:8016] {msandbox} ((none)) > show warnings;
+-------+------+---------------------------------------------------------------------+
| Level | Code | Message                                                             |
+-------+------+---------------------------------------------------------------------+
| Note  | 1585 | This function 'format_bytes' has the same name as a native function |
+-------+------+---------------------------------------------------------------------+
1 row in set (0.00 sec)

Suggested fix:
An easy fix, switch to the native function:

mysql [localhost:8016] {msandbox} ((none)) >  SELECT SUBSTRING_INDEX(event_name,'/',2) AS code_area, format_bytes(SUM(current_alloc)) AS current_alloc FROM sys.x$memory_global_by_current_bytes GROUP BY SUBSTRING_INDEX(event_name,'/',2) ORDER BY SUM(current_alloc) DESC;
+---------------------------+---------------+
| code_area                 | current_alloc |
+---------------------------+---------------+
| memory/performance_schema | 266.76 MiB    |
| memory/innodb             | 185.10 MiB    |
| memory/mysys              | 8.57 MiB      |
| memory/sql                | 3.45 MiB      |
| memory/temptable          | 1.00 MiB      |
| memory/mysqld_openssl     | 130.29 KiB    |
| memory/mysqlx             | 3.44 KiB      |
| memory/myisam             |  696 bytes    |
| memory/vio                |  656 bytes    |
| memory/csv                |   88 bytes    |
| memory/blackhole          |   88 bytes    |
+---------------------------+---------------+
11 rows in set (0.01 sec)
[7 Sep 2019 6:14] MySQL Verification Team
Hello Morgan,

Thank you for the report and feedback.

regards,
Umesh
[9 Sep 2019 15:52] Jon Stephens
Hi Morgan,

Thanks for the heads-up.

Fixed in mysqldoc rev 63415, fix should be online soon.

cheers

jon.