Merge pull request #10168 from nextcloud/bugfix/10163/allow-utf8mb4-on-maria-10.3-or-later

MySQL 8.0+ and MariaDB 10.3+ are large prefix and barracuda by default
This commit is contained in:
Morris Jobke 2018-07-13 16:23:36 +02:00 committed by GitHub
commit 1801e4e03f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 4 deletions

View File

@ -34,17 +34,36 @@ class MySqlTools {
* @return bool * @return bool
*/ */
public function supports4ByteCharset(IDBConnection $connection) { 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'"); $result = $connection->executeQuery("SHOW VARIABLES LIKE '$var'");
$rows = $result->fetch(); $row = $result->fetch();
$result->closeCursor(); $result->closeCursor();
if ($rows === false) { if ($row === false) {
return false; return false;
} }
if (strcasecmp($rows['Value'], $val) !== 0) { if (strcasecmp($row['Value'], $val) !== 0) {
return false; return false;
} }
} }
return true; 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', '>=');
}
} }