diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d36f5f9..da1841d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ ## Adminer dev -- PostgreSQL: Show partitioned tables as tables, not views +- PostgreSQL: Move partitioned tables from table list to parent table - Designs: adminer.css with 'prefers-color-scheme: dark' don't disable dark mode - Plugins: Method bodyClass() to add <body class> diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index 0fd1073b..066278f2 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -324,6 +324,16 @@ if (isset($_GET["pgsql"])) { } } + function inheritedTables(string $table): array { + return get_vals("SELECT c.relname +FROM pg_class p +JOIN pg_namespace n ON n.nspname = current_schema() AND n.oid = p.relnamespace +JOIN pg_inherits ON inhparent = p.oid +JOIN pg_class c ON inhrelid = c.oid +WHERE p.relname = " . q($table) . " AND p.relkind = 'p' +ORDER BY 1"); + } + function supportsIndex(array $table_status): bool { // returns true for "materialized view" return $table_status["Engine"] != "view"; @@ -415,9 +425,10 @@ ORDER BY 1"; c.reltuples as \"Rows\", n.nspname FROM pg_class c -JOIN pg_namespace n ON(n.nspname = current_schema() AND n.oid = c.relnamespace) +JOIN pg_namespace n ON n.nspname = current_schema() AND n.oid = c.relnamespace +LEFT JOIN pg_inherits ON inhrelid = c.oid WHERE relkind IN ('r', 'm', 'v', 'f', 'p') -" . ($name != "" ? "AND relname = " . q($name) : "ORDER BY relname")) as $row //! Index_length, Auto_increment +" . ($name != "" ? "AND relname = " . q($name) : "AND inhparent IS NULL ORDER BY relname")) as $row //! Auto_increment ) { $return[$row["Name"]] = $row; } diff --git a/adminer/include/driver.inc.php b/adminer/include/driver.inc.php index 5eea1838..0496ddbf 100644 --- a/adminer/include/driver.inc.php +++ b/adminer/include/driver.inc.php @@ -217,6 +217,13 @@ abstract class SqlDriver { function tableHelp(string $name, bool $is_view = false) { } + /** Get inherited tables + * @return list + */ + function inheritedTables(string $table): array { + return array(); + } + /** Check if C-style escapes are supported */ function hasCStyleEscapes(): bool { return false; diff --git a/adminer/lang/cs.inc.php b/adminer/lang/cs.inc.php index 21c4575d..fb26d01a 100644 --- a/adminer/lang/cs.inc.php +++ b/adminer/lang/cs.inc.php @@ -194,6 +194,7 @@ Lang::$translations = array( 'Partitions' => 'Oddíly', 'Partition name' => 'Název oddílu', 'Values' => 'Hodnoty', + 'Inherited tables' => 'Zděděné tabulky', 'View' => 'Pohled', 'Materialized view' => 'Materializovaný pohled', diff --git a/adminer/lang/xx.inc.php b/adminer/lang/xx.inc.php index 7217c8a4..51a8ede6 100644 --- a/adminer/lang/xx.inc.php +++ b/adminer/lang/xx.inc.php @@ -196,6 +196,7 @@ Lang::$translations = array( 'Partitions' => 'Xx', 'Partition name' => 'Xx', 'Values' => 'Xx', + 'Inherited tables' => 'Xx', 'View' => 'Xx', 'Materialized view' => 'Xx', diff --git a/adminer/table.inc.php b/adminer/table.inc.php index 4388c550..fc3a3b0e 100644 --- a/adminer/table.inc.php +++ b/adminer/table.inc.php @@ -95,3 +95,13 @@ if (support(is_view($table_status) ? "view_trigger" : "trigger")) { } echo '

" . lang('Inherited tables') . "

\n"; + echo "\n"; +}