From 8783f4d3accb3684e3b3302be42f8f44cc89c2fe Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Mon, 14 Apr 2025 13:13:08 +0200 Subject: [PATCH] PostgreSQL: Include inherited tables in table_status (bug #1031) --- adminer/drivers/pgsql.inc.php | 3 ++- adminer/include/adminer.inc.php | 2 +- phpstan.neon | 2 +- plugins/menu-links.php | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index 49850650..26855a76 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -427,12 +427,13 @@ ORDER BY 1"; obj_description(oid, 'pg_class') AS \"Comment\", " . (min_version(12) ? "''" : "CASE WHEN relhasoids THEN 'oid' ELSE '' END") . " AS \"Oid\", reltuples as \"Rows\", + inhparent AS inherited, current_schema() AS nspname FROM pg_class LEFT JOIN pg_inherits ON inhrelid = oid WHERE relkind IN ('r', 'm', 'v', 'f', 'p') AND relnamespace = " . driver()->nsOid . " -AND " . ($name != "" ? "relname = " . q($name) : "inhparent IS NULL ORDER BY relname")) as $row //! Auto_increment +" . ($name != "" ? "AND relname = " . q($name) : "ORDER BY relname")) as $row //! Auto_increment ) { $return[$row["Name"]] = $row; } diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 463c4ff8..dd3af767 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -1083,7 +1083,7 @@ class Adminer { foreach ($tables as $table => $status) { $table = "$table"; // do not highlight "0" as active everywhere $name = adminer()->tableName($status); - if ($name != "") { + if ($name != "" && !$status["inherited"]) { echo '
  • " . lang('select') . " " diff --git a/phpstan.neon b/phpstan.neon index f07f0536..05b6004e 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -61,7 +61,7 @@ parameters: max: 80499 typeAliases: - TableStatus: "array{Name:string, Engine?:?string, Comment?:string, Oid?:numeric-string, Rows?:?numeric-string, Collation?:string, Auto_increment?:?numeric-string, Data_length?:numeric-string, Index_length?:numeric-string, Data_free?:numeric-string, Create_options?:string, nspname?:string}" + TableStatus: "array{Name:string, Engine?:?string, Comment?:string, Oid?:numeric-string, Rows?:?numeric-string, Collation?:string, Auto_increment?:?numeric-string, Data_length?:numeric-string, Index_length?:numeric-string, Data_free?:numeric-string, Create_options?:string, inherited?:numeric-string, nspname?:string}" Field: "array{field?:string, full_type:string, type:string, length:numeric-string, unsigned:string, default?:string, null:bool, auto_increment:bool, collation:string, privileges:int[], comment:string, primary:bool, generated:string, orig?:string, on_update?:string, on_delete?:string, default_constraint?: string}" FieldType: "array{type:string, length:numeric-string, unsigned:string, collation:string}" # subset of RoutineField and Field RoutineField: "array{field:string, type:string, length:numeric-string, unsigned:string, null:bool, full_type:string, collation:string, inout?:string}" diff --git a/plugins/menu-links.php b/plugins/menu-links.php index 83e4a483..544f2cfe 100644 --- a/plugins/menu-links.php +++ b/plugins/menu-links.php @@ -36,7 +36,7 @@ class AdminerMenuLinks extends Adminer\Plugin { foreach ($tables as $table => $status) { $table = "$table"; // do not highlight "0" as active everywhere $name = Adminer\adminer()->tableName($status); - if ($name != "") { + if ($name != "" && !$status["inherited"]) { echo '
  • '; if (!$menu) { echo '