]> git.joonet.de Git - adminer.git/commitdiff
PostgreSQL: Fix starting value of exported autoincrement
authorPeter Knut <peter@pematon.com>
Thu, 30 Jan 2025 19:48:53 +0000 (20:48 +0100)
committerJakub Vrana <jakub@vrana.cz>
Wed, 19 Feb 2025 10:16:44 +0000 (11:16 +0100)
Thanks to @OmlineEditor (https://github.com/adminerevo/adminerevo/issues/113)

adminer/drivers/pgsql.inc.php

index 140408838f08d601c1383b48d697b1ce501e6659..3179b698e2adcd8d006fc7648c019df72e612027 100644 (file)
@@ -753,8 +753,6 @@ AND typelem = 0"
        }
 
        function create_sql($table, $auto_increment, $style) {
-               global $connection;
-               $return = '';
                $return_parts = array();
                $sequences = array();
 
@@ -789,7 +787,10 @@ AND typelem = 0"
                                        : "SELECT * FROM $sequence_name"
                                ));
                                $sequences[] = ($style == "DROP+CREATE" ? "DROP SEQUENCE IF EXISTS $sequence_name;\n" : "")
-                                       . "CREATE SEQUENCE $sequence_name INCREMENT $sq[increment_by] MINVALUE $sq[min_value] MAXVALUE $sq[max_value]" . ($auto_increment && $sq['last_value'] ? " START $sq[last_value]" : "") . " CACHE $sq[cache_value];";
+                                       . "CREATE SEQUENCE $sequence_name INCREMENT $sq[increment_by] MINVALUE $sq[min_value] MAXVALUE $sq[max_value]"
+                                       . ($auto_increment && $sq['last_value'] ? " START " . ($sq["last_value"] + 1) : "")
+                                       . " CACHE $sq[cache_value];"
+                               ;
                        }
                }