]> git.joonet.de Git - adminer.git/commitdiff
PostgreSQL: Fix editing data in views (bug #605)
authorJakub Vrana <jakub@vrana.cz>
Sun, 11 Mar 2018 15:41:04 +0000 (16:41 +0100)
committerJakub Vrana <jakub@vrana.cz>
Sun, 11 Mar 2018 15:41:04 +0000 (16:41 +0100)
adminer/drivers/pgsql.inc.php
changes.txt

index db962e0241b881bffcbd1b0d93ff9e6a26a8fe39..01e2cb519f02ff4fc8f791d45a52077b2de6c1f8 100644 (file)
@@ -217,7 +217,7 @@ if (isset($_GET["pgsql"])) {
                function convertSearch($idf, $val, $field) {
                        return (preg_match('~char|text'
                                        . (!preg_match('~LIKE~', $val["op"]) ? '|date|time(stamp)?' . (is_numeric($val["val"]) ? '|' . number_type() : '') : '')
-                                       . '~', $field["type"]) || $val["op"] == "SQL"
+                                       . '~', $field["type"])
                                ? $idf
                                : "CAST($idf AS text)"
                        );
@@ -286,7 +286,7 @@ if (isset($_GET["pgsql"])) {
        function limit1($table, $query, $where, $separator = "\n") {
                return (preg_match('~^INTO~', $query)
                        ? limit($query, $where, 1, 0, $separator)
-                       : " $query WHERE ctid = (SELECT ctid FROM " . table($table) . $where . $separator . "LIMIT 1)"
+                       : " $query" . (is_view(table_status1($table)) ? $where : " WHERE ctid = (SELECT ctid FROM " . table($table) . $where . $separator . "LIMIT 1)")
                );
        }
 
@@ -845,7 +845,7 @@ AND typelem = 0"
                $structured_types[$key] = array_keys($val);
        }
        $unsigned = array();
-       $operators = array("=", "<", ">", "<=", ">=", "!=", "~", "!~", "LIKE", "LIKE %%", "ILIKE", "ILIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL");
+       $operators = array("=", "<", ">", "<=", ">=", "!=", "~", "!~", "LIKE", "LIKE %%", "ILIKE", "ILIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL"); // no "SQL" to avoid SQL injection
        $functions = array("char_length", "lower", "round", "to_hex", "to_timestamp", "upper");
        $grouping = array("avg", "count", "count distinct", "max", "min", "sum");
        $edit_functions = array(
index a603fc799387785b12a716575746287b370f038f..3416bff40f77bb8035b4610ec9eb2f3d917e1857 100644 (file)
@@ -5,6 +5,7 @@ Decrease timeout for running slow queries from 5 seconds to 2 seconds
 Fix displaying info about non-alphabetical objects (bug #599)
 PDO: Support binary fields download
 MySQL: Use CONVERT() only when searching for non-ASCII (bug #603)
+PostgreSQL: Fix editing data in views (bug #605, regression from 4.6.0)
 PostgreSQL: Do not cast date/time searches to text
 PostgreSQL: Add SQL operator to search