diff options
author | Björn Schießle <bjoern@schiessle.org> | 2016-09-08 13:21:10 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-08 13:21:10 +0300 |
commit | 4d38425c949b5ac4e49b76b8ea1ff3d94735b56b (patch) | |
tree | c40d00a1c82a27aa1f12bfc43f851302ad532498 /lib | |
parent | 11d301ac3ab4f03a83fd0784e7f5b616619666f4 (diff) | |
parent | 3ceadd822679dd1d6f288fd81a4ab0397b3c534b (diff) |
Merge pull request #34 from nextcloud/fix-size-for-mariadbv9.0.54RC1v9.0.54
Fix size calculation for MariaDB
Diffstat (limited to 'lib')
-rw-r--r-- | lib/DatabaseStatistics.php | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/lib/DatabaseStatistics.php b/lib/DatabaseStatistics.php index 02804b9..50abfa8 100644 --- a/lib/DatabaseStatistics.php +++ b/lib/DatabaseStatistics.php @@ -92,26 +92,16 @@ class DatabaseStatistics { // This code is heavily influenced by a similar routine in phpMyAdmin 2.2.0 switch ($this->config->getSystemValue('dbtype')) { case 'mysql': - $sql = 'SELECT VERSION() AS mysql_version'; + $db_name = $this->config->getSystemValue('dbname'); + $sql = 'SHOW TABLE STATUS FROM ' . $db_name; $result = $this->connection->executeQuery($sql); - $row = $result->fetch(); - $result->closeCursor(); - if ($row) { - $version = $row['mysql_version']; - if (preg_match('#(3\.23|[45]\.)#', $version)) { - $db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.#', $version)) ? "`{$this->config->getSystemValue('dbname')}`" : $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'))) { - $database_size += $row['Data_length'] + $row['Index_length']; - } - } - $result->closeCursor(); + $database_size = 0; + while ($row = $result->fetch()) { + if ((isset($row['Type']) && $row['Type'] !== 'MRG_MyISAM') || (isset($row['Engine']) && ($row['Engine'] === 'MyISAM' || $row['Engine'] === 'InnoDB'))) { + $database_size += $row['Data_length'] + $row['Index_length']; } } + $result->closeCursor(); break; case 'sqlite': case 'sqlite3': |