]> git.joonet.de Git - adminer.git/commitdiff
PostgreSQL < 10 PDO: Avoid displaying GENERATED ALWAYS BY IDENTITY everywhere (bug...
authorJakub Vrana <jakub@vrana.cz>
Mon, 15 Feb 2021 17:31:47 +0000 (18:31 +0100)
committerJakub Vrana <jakub@vrana.cz>
Mon, 15 Feb 2021 17:33:19 +0000 (18:33 +0100)
adminer/drivers/pgsql.inc.php
changes.txt

index 402b2555dc4dc470830b5b3ce1b7472c21082db0..af6f2bfd429097de16e3da46d184584c1c6edcf2 100644 (file)
@@ -348,9 +348,7 @@ WHERE relkind IN ('r', 'm', 'v', 'f', 'p')
                        'timestamp with time zone' => 'timestamptz',
                );
 
-               $identity_column = min_version(10) ? 'a.attidentity' : '0';
-
-               foreach (get_rows("SELECT a.attname AS field, format_type(a.atttypid, a.atttypmod) AS full_type, pg_get_expr(d.adbin, d.adrelid) AS default, a.attnotnull::int, col_description(c.oid, a.attnum) AS comment, $identity_column AS identity
+               foreach (get_rows("SELECT a.attname AS field, format_type(a.atttypid, a.atttypmod) AS full_type, pg_get_expr(d.adbin, d.adrelid) AS default, a.attnotnull::int, col_description(c.oid, a.attnum) AS comment" . (min_version(10) ? ", a.attidentity" : "") . "
 FROM pg_class c
 JOIN pg_namespace n ON c.relnamespace = n.oid
 JOIN pg_attribute a ON c.oid = a.attrelid
@@ -373,11 +371,11 @@ ORDER BY a.attnum"
                                $row["type"] = $type;
                                $row["full_type"] = $row["type"] . $length . $addon . $array;
                        }
-                       if (in_array($row['identity'], array('a', 'd'))) {
-                               $row['default'] = 'GENERATED ' . ($row['identity'] == 'd' ? 'BY DEFAULT' : 'ALWAYS') . ' AS IDENTITY';
+                       if (in_array($row['attidentity'], array('a', 'd'))) {
+                               $row['default'] = 'GENERATED ' . ($row['attidentity'] == 'd' ? 'BY DEFAULT' : 'ALWAYS') . ' AS IDENTITY';
                        }
                        $row["null"] = !$row["attnotnull"];
-                       $row["auto_increment"] = $row['identity'] || preg_match('~^nextval\(~i', $row["default"]);
+                       $row["auto_increment"] = $row['attidentity'] || 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 58217ca1df2025e0b86b2d7a418b1bb78be5042f..98eee223af9bd6c4eb140056ae252f011ec1d901 100644 (file)
@@ -1,6 +1,7 @@
 Adminer 4.8.1-dev:
 Fix more PHP 8 warnings (bug #781)
 MySQL: Allow moving views to other DB and renaming DB with views (bug #783)
+PostgreSQL < 10 PDO: Avoid displaying GENERATED ALWAYS BY IDENTITY everywhere (bug #785, regression from 4.7.9)
 SQLite: Fix displayed types (bug #784, regression from 4.8.0)
 
 Adminer 4.8.0 (released 2021-02-10):