diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index 36224b77..af6d0f0f 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -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])); diff --git a/changes.txt b/changes.txt index 6cdbe4d5..7244897d 100644 --- a/changes.txt +++ b/changes.txt @@ -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