]> git.joonet.de Git - adminer.git/commitdiff
PostgreSQL: Support for GENERATED BY DEFAULT AS IDENTITY
authorsartor <sartorua@gmail.com>
Sat, 20 Oct 2018 17:34:28 +0000 (20:34 +0300)
committerJakub Vrana <jakub@vrana.cz>
Sat, 27 Oct 2018 17:42:01 +0000 (19:42 +0200)
adminer/drivers/pgsql.inc.php
changes.txt

index 36224b7798ee6d6fb8906c8b07e5aac373e5cf12..af6d0f0fcf29d1179e2123ef938d6b926b5c5f03 100644 (file)
@@ -349,7 +349,10 @@ WHERE relkind IN ('r', 'm', 'v', 'f')
                        'timestamp without time zone' => 'timestamp',
                        'timestamp with time zone' => 'timestamptz',
                );
-               foreach (get_rows("SELECT a.attname AS field, format_type(a.atttypid, a.atttypmod) AS full_type, d.adsrc AS default, a.attnotnull::int, col_description(c.oid, a.attnum) AS comment
+
+        $identity_column = min_version(10) ? "(a.attidentity = 'd')::int" : '0';
+
+               foreach (get_rows("SELECT a.attname AS field, format_type(a.atttypid, a.atttypmod) AS full_type, d.adsrc AS default, a.attnotnull::int, col_description(c.oid, a.attnum) AS comment, $identity_column AS identity
 FROM pg_class c
 JOIN pg_namespace n ON c.relnamespace = n.oid
 JOIN pg_attribute a ON c.oid = a.attrelid
@@ -372,8 +375,11 @@ ORDER BY a.attnum"
                                $row["type"] = $type;
                                $row["full_type"] = $row["type"] . $length . $addon . $array;
                        }
+                       if ($row['identity']) {
+                           $row['default'] = 'GENERATED BY DEFAULT AS IDENTITY';
+            }
                        $row["null"] = !$row["attnotnull"];
-                       $row["auto_increment"] = preg_match('~^nextval\(~i', $row["default"]);
+                       $row["auto_increment"] = $row['identity'] || preg_match('~^nextval\(~i', $row["default"]);
                        $row["privileges"] = array("insert" => 1, "select" => 1, "update" => 1);
                        if (preg_match('~(.+)::[^)]+(.*)~', $row["default"], $match)) {
                                $row["default"] = ($match[1] == "NULL" ? null : (($match[1][0] == "'" ? idf_unescape($match[1]) : $match[1]) . $match[2]));
index 6cdbe4d567644bdc96bc2c9a9f0f21070ab59b60..7244897d6056155fb387135c33466638c4cd0d86 100644 (file)
@@ -12,6 +12,7 @@ MySQL: Support foreign keys created with ANSI quotes (bug #620)
 MySQL: Recognize ON UPDATE current_timestamp() (bug #632, bug #638)
 PostgreSQL: Quote array values in export (bug #621)
 PostgreSQL: Export DESC indexes (bug #639)
+PostgreSQL: Support GENERATED BY DEFAULT AS IDENTITY in PostgreSQL 10
 MSSQL: Pass database when connecting
 ClickHouse: Connect, databases list, tables list, select, SQL command
 Georgian translation