]> git.joonet.de Git - adminer.git/commitdiff
SQLite: Limit rows in data manipulation without unique key
authorJakub Vrana <jakub@vrana.cz>
Thu, 1 Feb 2018 17:47:57 +0000 (18:47 +0100)
committerJakub Vrana <jakub@vrana.cz>
Thu, 1 Feb 2018 17:47:57 +0000 (18:47 +0100)
adminer/drivers/pgsql.inc.php
adminer/drivers/sqlite.inc.php
changes.txt

index 733b4c5b916c938625c31d99a941f7a1607e577e..5e7b5c64abdf33251ef997c9cd333f84c9b674d7 100644 (file)
@@ -227,7 +227,10 @@ if (isset($_GET["pgsql"])) {
        }
 
        function limit1($table, $query, $where) {
-               return (preg_match('~^INTO~', $query) ? limit($query, $where, 1) : "$query WHERE ctid = (SELECT ctid FROM " . table($table) . "$where LIMIT 1)");
+               return (preg_match('~^INTO~', $query)
+                       ? limit($query, $where, 1)
+                       : " $query WHERE ctid = (SELECT ctid FROM " . table($table) . "$where LIMIT 1)"
+               );
        }
 
        function db_collation($db, $collations) {
index 9d8efbb3235bfccf9c8bcad8b9bac3c37fbec54c..454ca9bdc48dec047364fcdfbb8ecf3f81fa5e61 100644 (file)
@@ -244,7 +244,10 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
 
        function limit1($table, $query, $where) {
                global $connection;
-               return ($connection->result("SELECT sqlite_compileoption_used('ENABLE_UPDATE_DELETE_LIMIT')") ? limit($query, $where, 1) : " $query$where"); //! limit
+               return (preg_match('~^INTO~', $query) || $connection->result("SELECT sqlite_compileoption_used('ENABLE_UPDATE_DELETE_LIMIT')")
+                       ? limit($query, $where, 1)
+                       : " $query WHERE rowid = (SELECT rowid FROM " . table($table) . "$where LIMIT 1)"
+               );
        }
 
        function db_collation($db, $collations) {
index 8e8a2dce0e663da8571a38391b7a1d2e8695c6a7..3e2c483ae8403481d804de6f7d7482c5e9aefb4e 100644 (file)
@@ -9,8 +9,8 @@ MySQL, PostgreSQL: Display warnings
 MySQL: Add floor and ceil select functions
 MySQL: Add FIND_IN_SET search operator
 MariaDB: Support JSON since MariaDB 10.2
+SQLite, PostgreSQL: Limit rows in data manipulation without unique key
 PostgreSQL: Support routines
-PostgreSQL: Limit rows in data manipulation without unique key
 PostgreSQL: Allow editing views with uppercase letters (bug #467)
 PostgreSQL: Allow now() as default value (bug #525)
 SimpleDB: Document that allow_url_fopen is required