From 25f9655a387d5ac1ee5543a442c693573aa18659 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Wed, 24 Jan 2018 17:11:11 +0100 Subject: [PATCH] Avoid CONVERT() except in MySQL (bug #509) --- adminer/include/adminer.inc.php | 2 +- adminer/select.inc.php | 4 ++-- changes.txt | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 1ca68fcc..95879e59 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -535,7 +535,7 @@ class Adminer { && (!preg_match("~[\x80-\xFF]~", $val["val"]) || $is_text) ) { $name = idf_escape($name); - $cols[] = ($jush == "sql" && $is_text && !preg_match("~^utf8_~", $field["collation"]) ? "CONVERT($name USING " . charset($connection) . ")" : $name); + $cols[] = ($jush == "sql" && $is_text && !preg_match("~^utf8~", $field["collation"]) ? "CONVERT($name USING " . charset($connection) . ")" : $name); } } $return[] = ($cols ? "(" . implode("$cond OR ", $cols) . "$cond)" : "0"); diff --git a/adminer/select.inc.php b/adminer/select.inc.php index 79a0a455..2e8d157a 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -364,9 +364,9 @@ if (!$columns && support("table")) { } $unique_idf = ""; foreach ($unique_array as $key => $val) { - if (($jush == "sql" || $jush == "pgsql") && strlen($val) > 64) { + if (($jush == "sql" || $jush == "pgsql") && preg_match('~char|text|enum|set~', $fields[$key]["type"]) && strlen($val) > 64) { $key = (strpos($key, '(') ? $key : idf_escape($key)); //! columns looking like functions - $key = "MD5(" . ($jush == 'sql' && preg_match("~^utf8_~", $fields[$key]["collation"]) ? $key : "CONVERT($key USING " . charset($connection) . ")") . ")"; + $key = "MD5(" . ($jush != 'sql' || preg_match("~^utf8~", $fields[$key]["collation"]) ? $key : "CONVERT($key USING " . charset($connection) . ")") . ")"; $val = md5($val); } $unique_idf .= "&" . ($val !== null ? urlencode("where[" . bracket_escape($key) . "]") . "=" . urlencode($val) : "null%5B%5D=" . urlencode($key)); diff --git a/changes.txt b/changes.txt index 64e88b13..117b38a5 100644 --- a/changes.txt +++ b/changes.txt @@ -15,6 +15,7 @@ PostgreSQL: Do not export triggers if not requested PostgreSQL: Export DROP SEQUENCE if dropping table PostgreSQL: Display boolean values as code (bug #562) MS SQL: Support freetds +non-MySQL: Avoid CONVERT() (bug #509) Elasticsearch: Insert, update, delete MongoDB: Support mongodb PHP extension Editor: Fix displaying of false values in PostgreSQL (bug #568)