diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index 5e208f0e..2169582b 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -73,6 +73,21 @@ function bracket_escape($idf, $back = false) { return strtr($idf, ($back ? array_flip($trans) : $trans)); } +/** Check if connection has at least the given version +* @param string required version +* @param string required MariaDB version +* @return bool +*/ +function min_version($version, $maria_db = "") { + global $connection; + $server_info = $connection->server_info; + if ($maria_db && preg_match('~([\d.]+)-MariaDB~', $server_info, $match)) { + $server_info = $match[1]; + $version = $maria_db; + } + return (version_compare($server_info, $version) >= 0); +} + /** Get connection charset * @param Min_DB * @return string diff --git a/adminer/indexes.inc.php b/adminer/indexes.inc.php index a430b9a9..222287a1 100644 --- a/adminer/indexes.inc.php +++ b/adminer/indexes.inc.php @@ -2,18 +2,10 @@ $TABLE = $_GET["indexes"]; $index_types = array("PRIMARY", "UNIQUE", "INDEX"); $table_status = table_status($TABLE, true); -$server_info = $connection->server_info; -$fulltext = ($server_info >= 5.6); -$spatial = ($server_info >= 5.7); -if (preg_match('~([\d.]+)-MariaDB~', $server_info, $match)) { - $server_info = $match[1]; - $fulltext = (version_compare($server_info, '10.0.5') >= 0); - $spatial = (version_compare($server_info, '10.2.2') >= 0); -} -if (preg_match('~MyISAM|M?aria' . ($fulltext ? '|InnoDB' : '') . '~i', $table_status["Engine"])) { +if (preg_match('~MyISAM|M?aria' . (min_version(5.6, '10.0.5') ? '|InnoDB' : '') . '~i', $table_status["Engine"])) { $index_types[] = "FULLTEXT"; } -if (preg_match('~MyISAM|M?aria' . ($spatial ? '|InnoDB' : '') . '~i', $table_status["Engine"])) { +if (preg_match('~MyISAM|M?aria' . (min_version(5.7, '10.2.2') ? '|InnoDB' : '') . '~i', $table_status["Engine"])) { $index_types[] = "SPATIAL"; } $indexes = indexes($TABLE);