diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index 3a974d1d..249b3dd2 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -277,6 +277,13 @@ if (!defined("DRIVER")) { return queries($prefix . implode(",\n", $values) . $suffix); } + function convertSearch($idf, $field) { + return (preg_match('~char|text|enum|set~', $field["type"]) && !preg_match("~^utf8~", $field["collation"]) + ? "CONVERT($idf USING " . charset($this->_conn) . ")" + : $idf + ); + } + function warnings() { $result = $this->_conn->query("SHOW WARNINGS"); if ($result && $result->num_rows) { diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 413ca3ba..4a1f2aae 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -504,7 +504,7 @@ class Adminer { * @return array expressions to join by AND */ function selectSearchProcess($fields, $indexes) { - global $connection, $jush; + global $connection, $driver; $return = array(); foreach ($indexes as $i => $index) { if ($index["type"] == "FULLTEXT" && $_GET["fulltext"][$i] != "") { @@ -534,17 +534,15 @@ class Adminer { $cond .= " " . $this->processInput($fields[$val["col"]], $val["val"]); } if ($val["col"] != "") { - $return[] = $prefix . idf_escape($val["col"]) . $cond; + $return[] = $prefix . $driver->convertSearch(idf_escape($val["col"]), $fields[$val["col"]]) . $cond; } else { // find anywhere $cols = array(); foreach ($fields as $name => $field) { - $is_text = preg_match('~char|text|enum|set~', $field["type"]); if ((is_numeric($val["val"]) || !preg_match('~' . number_type() . '|bit~', $field["type"])) - && (!preg_match("~[\x80-\xFF]~", $val["val"]) || $is_text) + && (!preg_match("~[\x80-\xFF]~", $val["val"]) || preg_match('~char|text|enum|set~', $field["type"])) ) { - $name = idf_escape($name); - $cols[] = $prefix . ($jush == "sql" && $is_text && !preg_match("~^utf8~", $field["collation"]) ? "CONVERT($name USING " . charset($connection) . ")" : $name) . $cond; + $cols[] = $prefix . $driver->convertSearch(idf_escape($name), $field) . $cond; } } $return[] = ($cols ? "(" . implode(" OR ", $cols) . ")" : "1 = 0"); diff --git a/adminer/include/driver.inc.php b/adminer/include/driver.inc.php index 69e1aa49..c16481aa 100644 --- a/adminer/include/driver.inc.php +++ b/adminer/include/driver.inc.php @@ -113,6 +113,15 @@ return queries("ROLLBACK"); } + /** Convert column to be searchable + * @param string escaped name + * @param array + * @return string + */ + function convertSearch($idf, $field) { + return $idf; + } + /** Get warnings about the last command * @return string HTML */ diff --git a/changes.txt b/changes.txt index 2550fb45..d3289bcf 100644 --- a/changes.txt +++ b/changes.txt @@ -1,4 +1,5 @@ Adminer 4.6.1-dev: +MySQL: Support non-utf8 charset in search in column MySQL: Support geometry in MySQL 8 (bug #574) PostgreSQL: Don't treat interval type as number (bug #474) PostgreSQL: Fix condition for selecting no rows