diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index 066278f2..21656465 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -324,6 +324,16 @@ if (isset($_GET["pgsql"])) { } } + function inheritsFrom(string $table): array { + return get_vals("SELECT p.relname +FROM pg_class c +JOIN pg_namespace n ON n.nspname = current_schema() AND n.oid = c.relnamespace +JOIN pg_inherits ON inhrelid = c.oid +JOIN pg_class p ON inhparent = p.oid +WHERE c.relname = " . q($table) . " AND c.relkind = 'r' +ORDER BY 1"); + } + function inheritedTables(string $table): array { return get_vals("SELECT c.relname FROM pg_class p diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index c58e6dbc..463c4ff8 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -184,6 +184,7 @@ class Adminer { * @param ?string $set new item options, NULL for no new item */ function selectLinks(array $tableStatus, ?string $set = ""): void { + $name = $tableStatus["Name"]; echo '
';
$links = array("select" => lang('Select data'));
if (support("table") || support("indexes")) {
@@ -194,14 +195,13 @@ class Adminer {
$is_view = is_view($tableStatus);
if ($is_view) {
$links["view"] = lang('Alter view');
- } else {
+ } elseif (!driver()->inheritsFrom($name)) {
$links["create"] = lang('Alter table');
}
}
if ($set !== null) {
$links["edit"] = lang('New item');
}
- $name = $tableStatus["Name"];
foreach ($links as $key => $val) {
echo " $val";
}
diff --git a/adminer/include/driver.inc.php b/adminer/include/driver.inc.php
index 0496ddbf..a7e05443 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 tables this table inherits from
+ * @return list " . lang('Comment') . ": " . h($comment) . "\n";
}
-if ($fields) {
+function tables_links($tables) {
+ echo "\n";
+ foreach ($tables as $table) {
+ echo "
\n";
+}
+
+$inherits = driver()->inheritsFrom($TABLE);
+if ($inherits) {
+ echo "" . lang('Inherits from') . "
\n";
+ tables_links($inherits);
+} elseif ($fields) {
adminer()->tableStructurePrint($fields, $table_status);
}
@@ -99,9 +111,5 @@ if (support(is_view($table_status) ? "view_trigger" : "trigger")) {
$inherited = driver()->inheritedTables($TABLE);
if ($inherited) {
echo "" . lang('Inherited tables') . "
\n";
- echo "\n";
- foreach ($inherited as $val) {
- echo "
\n";
+ tables_links($inherited);
}