diff options
author | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2020-06-10 19:29:25 +0300 |
---|---|---|
committer | Vicențiu Ciorbaru <vicentiu@mariadb.org> | 2020-06-10 19:29:25 +0300 |
commit | ae3a7d5e4372c4be933c867348d9bc6fca82db24 (patch) | |
tree | cc9653454b7b961261e2eaf4e4b4beee8870baf0 /plugin | |
parent | 59717bbce4465334dd94a05b3329e89ab8e9690e (diff) | |
download | mariadb-git-ae3a7d5e4372c4be933c867348d9bc6fca82db24.tar.gz |
MDEV-22834: Disks plugin - change datatype to bigint
On large hard disks (> 2TB), the plugin won't function correctly, always
showing 2 TB of available space due to integer overflow. Upgrade table
fields to bigint to resolve this problem.
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/disks/information_schema_disks.cc | 13 | ||||
-rw-r--r-- | plugin/disks/mysql-test/disks/disks.result | 6 |
2 files changed, 10 insertions, 9 deletions
diff --git a/plugin/disks/information_schema_disks.cc b/plugin/disks/information_schema_disks.cc index c4b558ba107..e3b0e96c2e7 100644 --- a/plugin/disks/information_schema_disks.cc +++ b/plugin/disks/information_schema_disks.cc @@ -32,9 +32,9 @@ ST_FIELD_INFO disks_table_fields[]= { { "Disk", PATH_MAX, MYSQL_TYPE_STRING, 0, 0 ,0, 0 }, { "Path", PATH_MAX, MYSQL_TYPE_STRING, 0, 0 ,0, 0 }, - { "Total", 32, MYSQL_TYPE_LONG, 0, 0 ,0 ,0 }, // Total amount available - { "Used", 32, MYSQL_TYPE_LONG, 0, 0 ,0 ,0 }, // Amount of space used - { "Available", 32, MYSQL_TYPE_LONG, 0, 0 ,0 ,0 }, // Amount available to users other than root. + { "Total", 32, MYSQL_TYPE_LONGLONG, 0, 0 ,0 ,0 }, // Total amount available + { "Used", 32, MYSQL_TYPE_LONGLONG, 0, 0 ,0 ,0 }, // Amount of space used + { "Available", 32, MYSQL_TYPE_LONGLONG, 0, 0 ,0 ,0 }, // Amount available to users other than root. { 0, 0, MYSQL_TYPE_NULL, 0, 0, 0, 0 } }; @@ -51,9 +51,10 @@ int disks_table_add_row(THD* pThd, // f_bfree Total number of free blocks. // f_bavail Number of free blocks available to non-privileged process. - size_t total = (info.f_frsize * info.f_blocks) / 1024; - size_t used = (info.f_frsize * (info.f_blocks - info.f_bfree)) / 1024; - size_t avail = (info.f_frsize * info.f_bavail) / 1024; + ulonglong total = ((ulonglong)info.f_frsize * info.f_blocks) / 1024; + ulonglong used = ((ulonglong)info.f_frsize * + (info.f_blocks - info.f_bfree)) / 1024; + ulonglong avail = ((ulonglong)info.f_frsize * info.f_bavail) / 1024; pTable->field[0]->store(zDisk, strlen(zDisk), system_charset_info); pTable->field[1]->store(zPath, strlen(zPath), system_charset_info); diff --git a/plugin/disks/mysql-test/disks/disks.result b/plugin/disks/mysql-test/disks/disks.result index bd6befc5e11..156eed29452 100644 --- a/plugin/disks/mysql-test/disks/disks.result +++ b/plugin/disks/mysql-test/disks/disks.result @@ -3,9 +3,9 @@ Table Create Table DISKS CREATE TEMPORARY TABLE `DISKS` ( `Disk` varchar(4096) NOT NULL DEFAULT '', `Path` varchar(4096) NOT NULL DEFAULT '', - `Total` int(32) NOT NULL DEFAULT '0', - `Used` int(32) NOT NULL DEFAULT '0', - `Available` int(32) NOT NULL DEFAULT '0' + `Total` bigint(32) NOT NULL DEFAULT '0', + `Used` bigint(32) NOT NULL DEFAULT '0', + `Available` bigint(32) NOT NULL DEFAULT '0' ) ENGINE=MEMORY DEFAULT CHARSET=utf8 select sum(Total) > sum(Available), sum(Total)>sum(Used) from information_schema.disks; sum(Total) > sum(Available) sum(Total)>sum(Used) |