Skip to content

Commit

Permalink
Merge pull request #261 from nextcloud/bugfix/noid/fix-db-size-on-mysql8
Browse files Browse the repository at this point in the history
Fix MySQL database size calculation
  • Loading branch information
nickvergessen authored Dec 14, 2020
2 parents 6bd12f1 + 999d64b commit d9cc64a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/DatabaseStatistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,13 @@ protected function databaseSize() {
// This code is heavily influenced by a similar routine in phpMyAdmin 2.2.0
switch ($this->config->getSystemValue('dbtype')) {
case 'mysql':
$mysqlEngine = ['MyISAM', 'InnoDB', 'Aria'];
$db_name = $this->config->getSystemValue('dbname');
$sql = 'SHOW TABLE STATUS FROM `' . $db_name . '`';
$result = $this->connection->executeQuery($sql);
$database_size = 0;
while ($row = $result->fetch()) {
if ((isset($row['Type']) && $row['Type'] !== 'MRG_MyISAM') || (isset($row['Engine']) && ($row['Engine'] === 'MyISAM' || $row['Engine'] === 'InnoDB'))) {
if (isset($row['Engine']) && in_array($row['Engine'], $mysqlEngine)) {
$database_size += $row['Data_length'] + $row['Index_length'];
}
}
Expand Down

0 comments on commit d9cc64a

Please sign in to comment.