diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-08-23 16:02:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-23 16:02:59 +0200 |
commit | 70fe04dada0fa072d6411b1653f6771393d187c1 (patch) | |
tree | b918f60e31bb801b9c0b53a04693eeb7c0ad8a5e | |
parent | 8a8eb605b4247fcfea3487bd24ed2cf61bde1872 (diff) | |
parent | d12ff2c0830adf61b1052f1b49d64f4fd951a9c3 (diff) | |
download | nextcloud-server-70fe04dada0fa072d6411b1653f6771393d187c1.tar.gz nextcloud-server-70fe04dada0fa072d6411b1653f6771393d187c1.zip |
Merge pull request #10823 from nextcloud/backport/10168/allow-utf8mb4-on-maria-10.3-or-later
[stable13] MySQL 8.0+ and MariaDB 10.3+ are large prefix and barracuda by default
-rw-r--r-- | lib/private/DB/MySqlTools.php | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/lib/private/DB/MySqlTools.php b/lib/private/DB/MySqlTools.php index 7f0ba473268..b67aaffe5b4 100644 --- a/lib/private/DB/MySqlTools.php +++ b/lib/private/DB/MySqlTools.php @@ -34,17 +34,36 @@ class MySqlTools { * @return bool */ public function supports4ByteCharset(IDBConnection $connection) { - foreach (['innodb_file_format' => 'Barracuda', 'innodb_large_prefix' => 'ON', 'innodb_file_per_table' => 'ON'] as $var => $val) { + $variables = ['innodb_file_per_table' => 'ON']; + if (!$this->isMariaDBWithLargePrefix($connection)) { + $variables['innodb_file_format'] = 'Barracuda'; + $variables['innodb_large_prefix'] = 'ON'; + } + + foreach ($variables as $var => $val) { $result = $connection->executeQuery("SHOW VARIABLES LIKE '$var'"); - $rows = $result->fetch(); + $row = $result->fetch(); $result->closeCursor(); - if ($rows === false) { + if ($row === false) { return false; } - if (strcasecmp($rows['Value'], $val) !== 0) { + if (strcasecmp($row['Value'], $val) !== 0) { return false; } } return true; } + + protected function isMariaDBWithLargePrefix(IDBConnection $connection) { + $result = $connection->executeQuery('SELECT VERSION()'); + $row = strtolower($result->fetchColumn()); + $result->closeCursor(); + + if ($row === false) { + return false; + } + + return strpos($row, 'maria') && version_compare($row, '10.3', '>=') || + strpos($row, 'maria') === false && version_compare($row, '8.0', '>='); + } } |