MySQL: Support non-utf8 charset in search in column
This commit is contained in:
parent
c2de3b8ec1
commit
197abdcb70
|
@ -277,6 +277,13 @@ if (!defined("DRIVER")) {
|
||||||
return queries($prefix . implode(",\n", $values) . $suffix);
|
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() {
|
function warnings() {
|
||||||
$result = $this->_conn->query("SHOW WARNINGS");
|
$result = $this->_conn->query("SHOW WARNINGS");
|
||||||
if ($result && $result->num_rows) {
|
if ($result && $result->num_rows) {
|
||||||
|
|
|
@ -504,7 +504,7 @@ class Adminer {
|
||||||
* @return array expressions to join by AND
|
* @return array expressions to join by AND
|
||||||
*/
|
*/
|
||||||
function selectSearchProcess($fields, $indexes) {
|
function selectSearchProcess($fields, $indexes) {
|
||||||
global $connection, $jush;
|
global $connection, $driver;
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach ($indexes as $i => $index) {
|
foreach ($indexes as $i => $index) {
|
||||||
if ($index["type"] == "FULLTEXT" && $_GET["fulltext"][$i] != "") {
|
if ($index["type"] == "FULLTEXT" && $_GET["fulltext"][$i] != "") {
|
||||||
|
@ -534,17 +534,15 @@ class Adminer {
|
||||||
$cond .= " " . $this->processInput($fields[$val["col"]], $val["val"]);
|
$cond .= " " . $this->processInput($fields[$val["col"]], $val["val"]);
|
||||||
}
|
}
|
||||||
if ($val["col"] != "") {
|
if ($val["col"] != "") {
|
||||||
$return[] = $prefix . idf_escape($val["col"]) . $cond;
|
$return[] = $prefix . $driver->convertSearch(idf_escape($val["col"]), $fields[$val["col"]]) . $cond;
|
||||||
} else {
|
} else {
|
||||||
// find anywhere
|
// find anywhere
|
||||||
$cols = array();
|
$cols = array();
|
||||||
foreach ($fields as $name => $field) {
|
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"]))
|
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 . $driver->convertSearch(idf_escape($name), $field) . $cond;
|
||||||
$cols[] = $prefix . ($jush == "sql" && $is_text && !preg_match("~^utf8~", $field["collation"]) ? "CONVERT($name USING " . charset($connection) . ")" : $name) . $cond;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$return[] = ($cols ? "(" . implode(" OR ", $cols) . ")" : "1 = 0");
|
$return[] = ($cols ? "(" . implode(" OR ", $cols) . ")" : "1 = 0");
|
||||||
|
|
|
@ -113,6 +113,15 @@
|
||||||
return queries("ROLLBACK");
|
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
|
/** Get warnings about the last command
|
||||||
* @return string HTML
|
* @return string HTML
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
Adminer 4.6.1-dev:
|
Adminer 4.6.1-dev:
|
||||||
|
MySQL: Support non-utf8 charset in search in column
|
||||||
MySQL: Support geometry in MySQL 8 (bug #574)
|
MySQL: Support geometry in MySQL 8 (bug #574)
|
||||||
PostgreSQL: Don't treat interval type as number (bug #474)
|
PostgreSQL: Don't treat interval type as number (bug #474)
|
||||||
PostgreSQL: Fix condition for selecting no rows
|
PostgreSQL: Fix condition for selecting no rows
|
||||||
|
|
Loading…
Reference in a new issue