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-12 11:34:45 +0300 |
commit | 8ec21afc8ed2df3b02815a45624b3287d5ffceae (patch) | |
tree | d25de0d2b961ecbc38389ee4db6b737668ab6d6e | |
parent | e156a8da08955445727385aee34ac9e2c735e4bd (diff) | |
download | mariadb-git-8ec21afc8ed2df3b02815a45624b3287d5ffceae.tar.gz |
MDEV-22834: Disks plugin - change datatype to bigintbb-10.5-mdev1501
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.
-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 6715d40f20d..042cfaffaa4 100644 --- a/plugin/disks/information_schema_disks.cc +++ b/plugin/disks/information_schema_disks.cc @@ -34,9 +34,9 @@ ST_FIELD_INFO disks_table_fields[]= { Column("Disk", Varchar(PATH_MAX), NOT_NULL), Column("Path", Varchar(PATH_MAX), NOT_NULL), - Column("Total", SLong(32), NOT_NULL), // Total amount available - Column("Used", SLong(32), NOT_NULL), // Amount of space used - Column("Available", SLong(32), NOT_NULL), // Amount available to users other than root. + Column("Total", SLonglong(32), NOT_NULL), // Total amount available + Column("Used", SLonglong(32), NOT_NULL), // Amount of space used + Column("Available", SLonglong(32), NOT_NULL), // Amount available to users other than root. CEnd() }; @@ -55,9 +55,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 65b1127d479..0b4ee6249aa 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) |