]> git.joonet.de Git - adminer.git/commitdiff
SQLite: Allow setting auto increment for empty tables
authorJakub Vrana <jakub@vrana.cz>
Wed, 21 Aug 2019 09:44:57 +0000 (11:44 +0200)
committerJakub Vrana <jakub@vrana.cz>
Wed, 21 Aug 2019 09:46:38 +0000 (11:46 +0200)
adminer/drivers/sqlite.inc.php
changes.txt

index 810b4ef4867c2b34755878c1251f91b43113b096..d49aee64fcf3d3d8e1bc51a9f3a77b42d5becc5b 100644 (file)
@@ -482,6 +482,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
        }
 
        function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) {
+               global $connection;
                $use_all_fields = ($table == "" || $foreign);
                foreach ($fields as $field) {
                        if ($field[0] != "" || !$field[1] || $field[2]) {
@@ -512,7 +513,12 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
                        return false;
                }
                if ($auto_increment) {
+                       queries("BEGIN");
                        queries("UPDATE sqlite_sequence SET seq = $auto_increment WHERE name = " . q($name)); // ignores error
+                       if (!$connection->affected_rows) {
+                               queries("INSERT INTO sqlite_sequence (name, seq) VALUES (" . q($name) . ", $auto_increment)");
+                       }
+                       queries("COMMIT");
                }
                return true;
        }
index f9614402a158571c86887f9600e017a30ce01c8f..298a3078c68bad319c3ca14833f324aa29a522d3 100644 (file)
@@ -4,6 +4,7 @@ MySQL: Allow editing rows identified by negative floats (bug #695)
 MySQL: Skip editing generated columns
 SQLite: Quote strings stored in integer columns in export (bug #696)
 SQLite: Handle error in altering table (bug #697)
+SQLite: Allow setting auto increment for empty tables
 
 Adminer 4.7.2 (released 2019-07-18):
 Do not attempt logging in without password (bug #676)