From 4a65703334cc70e24835ce24db5e8c7c99bd9977 Mon Sep 17 00:00:00 2001 From: Peter Knut Date: Wed, 29 Jan 2025 23:18:10 +0100 Subject: [PATCH] MariaDB: Fix missing uca1400 collations Since MariaDB 10.10, one collation can be compatible with more character sets, so collations no longer have unique IDs. Thanks to @shionryuu (https://github.com/adminerevo/adminerevo/issues/50) --- adminer/drivers/mysql.inc.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index 789d071b..09a984fb 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -642,8 +642,17 @@ if (isset($_GET["mysql"])) { * @return array */ function collations() { + global $connection; + $return = array(); - foreach (get_rows("SHOW COLLATION") as $row) { + + // Since MariaDB 10.10, one collation can be compatible with more character sets, so collations no longer have unique IDs. + // All combinations can be selected from information_schema.COLLATION_CHARACTER_SET_APPLICABILITY table. + $query = min_version('', '10.10', $connection) ? + "SELECT CHARACTER_SET_NAME AS Charset, FULL_COLLATION_NAME AS Collation, IS_DEFAULT AS `Default` FROM information_schema.COLLATION_CHARACTER_SET_APPLICABILITY" : + "SHOW COLLATION"; + + foreach (get_rows($query) as $row) { if ($row["Default"]) { $return[$row["Charset"]][-1] = $row["Collation"]; } else { @@ -651,9 +660,11 @@ if (isset($_GET["mysql"])) { } } ksort($return); + foreach ($return as $key => $val) { asort($return[$key]); } + return $return; }