]> git.joonet.de Git - adminer.git/commitdiff
Use primary key instead of LIMIT 1 if available
authorJakub Vrana <jakub@vrana.cz>
Mon, 5 Feb 2018 10:21:19 +0000 (11:21 +0100)
committerJakub Vrana <jakub@vrana.cz>
Mon, 5 Feb 2018 10:21:19 +0000 (11:21 +0100)
adminer/drivers/sqlite.inc.php
adminer/include/version.inc.php
adminer/select.inc.php

index 4809c31dd8835b359931468696d381d90a2a9a5f..a6db193bb31234462d2e62d37e4a5054efa2c5b4 100644 (file)
@@ -246,7 +246,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
                global $connection;
                return (preg_match('~^INTO~', $query) || $connection->result("SELECT sqlite_compileoption_used('ENABLE_UPDATE_DELETE_LIMIT')")
                        ? limit($query, $where, 1, 0, $separator)
-                       : " $query WHERE rowid = (SELECT rowid FROM " . table($table) . $where . $separator . "LIMIT 1)"
+                       : " $query WHERE rowid = (SELECT rowid FROM " . table($table) . $where . $separator . "LIMIT 1)" //! use primary key in tables with WITHOUT rowid
                );
        }
 
index 322393d449bc2c0e111ec2b87d61ccb189b573ce..32fb98a2d716c8644d4582dbe7f38fcdbf43fc04 100644 (file)
@@ -1,2 +1,2 @@
 <?php
-$VERSION = "4.6.0";
+$VERSION = "4.6.1-dev";
index 8be701f8648ab4fc10b18c474939aaa8459e89a5..5a3cf6d11dab16eb6a80f17312cde0e04381200b 100644 (file)
@@ -54,7 +54,7 @@ foreach ($indexes as $index) {
                break;
        }
 }
-if ($oid && $unselected === null) {
+if ($oid && !$primary) {
        $primary = $unselected = array($oid => 0);
        $indexes[] = array("type" => "PRIMARY", "columns" => array($oid));
 }
@@ -77,7 +77,7 @@ if ($_POST && !$error) {
                        . convert_fields($columns, $fields, $select)
                        . "\nFROM " . table($TABLE);
                $group_by = ($group && $is_group ? "\nGROUP BY " . implode(", ", $group) : "") . ($order ? "\nORDER BY " . implode(", ", $order) : "");
-               if (!is_array($_POST["check"]) || $unselected === array()) {
+               if (!is_array($_POST["check"]) || $primary) {
                        $query = "SELECT $from$where_check$group_by";
                } else {
                        $union = array();
@@ -108,7 +108,7 @@ if ($_POST && !$error) {
                                if ($_POST["clone"]) {
                                        $query = "INTO " . table($TABLE) . " (" . implode(", ", array_keys($set)) . ")\nSELECT " . implode(", ", $set) . "\nFROM " . table($TABLE);
                                }
-                               if ($_POST["all"] || ($unselected === array() && is_array($_POST["check"])) || $is_group) {
+                               if ($_POST["all"] || ($primary && is_array($_POST["check"])) || $is_group) {
                                        $result = ($_POST["delete"]
                                                ? $driver->delete($TABLE, $where_check)
                                                : ($_POST["clone"]
@@ -165,7 +165,7 @@ if ($_POST && !$error) {
                                                $TABLE,
                                                $set,
                                                " WHERE " . ($where ? implode(" AND ", $where) . " AND " : "") . where_check($unique_idf, $fields),
-                                               !($is_group || $unselected === array()),
+                                               !$is_group && !$primary,
                                                " "
                                        );
                                        if (!$result) {