]> git.joonet.de Git - adminer.git/commitdiff
Avoid CONVERT() except in MySQL (bug #509)
authorJakub Vrana <jakub@vrana.cz>
Wed, 24 Jan 2018 16:11:11 +0000 (17:11 +0100)
committerJakub Vrana <jakub@vrana.cz>
Wed, 24 Jan 2018 16:37:14 +0000 (17:37 +0100)
adminer/include/adminer.inc.php
adminer/select.inc.php
changes.txt

index 1ca68fcc813933ce3b430379569927a1f689b397..95879e59161ce627ac4e4a7f8ba8bfbadd5d83c9 100644 (file)
@@ -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");
index 79a0a455362712d91ac68cbf7a8d47abc77c1289..2e8d157a19cbea43b8f31c1a99a66a46c44eb357 100644 (file)
@@ -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));
index 64e88b137fdb5d58f05996805f122b3dd4093e96..117b38a585f29018cb8ea1405e48434302f5ad24 100644 (file)
@@ -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)