mirror of
https://github.com/vrana/adminer.git
synced 2025-08-06 22:56:46 +02:00
PostgreSQL: Link parent from inherited tables (bug #1031)
This commit is contained in:
@@ -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 {
|
function inheritedTables(string $table): array {
|
||||||
return get_vals("SELECT c.relname
|
return get_vals("SELECT c.relname
|
||||||
FROM pg_class p
|
FROM pg_class p
|
||||||
|
@@ -184,6 +184,7 @@ class Adminer {
|
|||||||
* @param ?string $set new item options, NULL for no new item
|
* @param ?string $set new item options, NULL for no new item
|
||||||
*/
|
*/
|
||||||
function selectLinks(array $tableStatus, ?string $set = ""): void {
|
function selectLinks(array $tableStatus, ?string $set = ""): void {
|
||||||
|
$name = $tableStatus["Name"];
|
||||||
echo '<p class="links">';
|
echo '<p class="links">';
|
||||||
$links = array("select" => lang('Select data'));
|
$links = array("select" => lang('Select data'));
|
||||||
if (support("table") || support("indexes")) {
|
if (support("table") || support("indexes")) {
|
||||||
@@ -194,14 +195,13 @@ class Adminer {
|
|||||||
$is_view = is_view($tableStatus);
|
$is_view = is_view($tableStatus);
|
||||||
if ($is_view) {
|
if ($is_view) {
|
||||||
$links["view"] = lang('Alter view');
|
$links["view"] = lang('Alter view');
|
||||||
} else {
|
} elseif (!driver()->inheritsFrom($name)) {
|
||||||
$links["create"] = lang('Alter table');
|
$links["create"] = lang('Alter table');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($set !== null) {
|
if ($set !== null) {
|
||||||
$links["edit"] = lang('New item');
|
$links["edit"] = lang('New item');
|
||||||
}
|
}
|
||||||
$name = $tableStatus["Name"];
|
|
||||||
foreach ($links as $key => $val) {
|
foreach ($links as $key => $val) {
|
||||||
echo " <a href='" . h(ME) . "$key=" . urlencode($name) . ($key == "edit" ? $set : "") . "'" . bold(isset($_GET[$key])) . ">$val</a>";
|
echo " <a href='" . h(ME) . "$key=" . urlencode($name) . ($key == "edit" ? $set : "") . "'" . bold(isset($_GET[$key])) . ">$val</a>";
|
||||||
}
|
}
|
||||||
|
@@ -217,6 +217,13 @@ abstract class SqlDriver {
|
|||||||
function tableHelp(string $name, bool $is_view = false) {
|
function tableHelp(string $name, bool $is_view = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get tables this table inherits from
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
function inheritsFrom(string $table): array {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
/** Get inherited tables
|
/** Get inherited tables
|
||||||
* @return list<string>
|
* @return list<string>
|
||||||
*/
|
*/
|
||||||
|
@@ -194,6 +194,7 @@ Lang::$translations = array(
|
|||||||
'Partitions' => 'Oddíly',
|
'Partitions' => 'Oddíly',
|
||||||
'Partition name' => 'Název oddílu',
|
'Partition name' => 'Název oddílu',
|
||||||
'Values' => 'Hodnoty',
|
'Values' => 'Hodnoty',
|
||||||
|
'Inherits from' => 'Zděděná z',
|
||||||
'Inherited tables' => 'Zděděné tabulky',
|
'Inherited tables' => 'Zděděné tabulky',
|
||||||
|
|
||||||
'View' => 'Pohled',
|
'View' => 'Pohled',
|
||||||
|
@@ -196,6 +196,7 @@ Lang::$translations = array(
|
|||||||
'Partitions' => 'Xx',
|
'Partitions' => 'Xx',
|
||||||
'Partition name' => 'Xx',
|
'Partition name' => 'Xx',
|
||||||
'Values' => 'Xx',
|
'Values' => 'Xx',
|
||||||
|
'Inherits from' => 'Xx',
|
||||||
'Inherited tables' => 'Xx',
|
'Inherited tables' => 'Xx',
|
||||||
|
|
||||||
'View' => 'Xx',
|
'View' => 'Xx',
|
||||||
|
@@ -22,7 +22,19 @@ if ($comment != "") {
|
|||||||
echo "<p class='nowrap'>" . lang('Comment') . ": " . h($comment) . "\n";
|
echo "<p class='nowrap'>" . lang('Comment') . ": " . h($comment) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($fields) {
|
function tables_links($tables) {
|
||||||
|
echo "<ul>\n";
|
||||||
|
foreach ($tables as $table) {
|
||||||
|
echo "<li><a href='" . h(ME . "table=" . urlencode($table)) . "'>" . h($table) . "</a>";
|
||||||
|
}
|
||||||
|
echo "</ul>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$inherits = driver()->inheritsFrom($TABLE);
|
||||||
|
if ($inherits) {
|
||||||
|
echo "<h3>" . lang('Inherits from') . "</h3>\n";
|
||||||
|
tables_links($inherits);
|
||||||
|
} elseif ($fields) {
|
||||||
adminer()->tableStructurePrint($fields, $table_status);
|
adminer()->tableStructurePrint($fields, $table_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,9 +111,5 @@ if (support(is_view($table_status) ? "view_trigger" : "trigger")) {
|
|||||||
$inherited = driver()->inheritedTables($TABLE);
|
$inherited = driver()->inheritedTables($TABLE);
|
||||||
if ($inherited) {
|
if ($inherited) {
|
||||||
echo "<h3 id='inherited'>" . lang('Inherited tables') . "</h3>\n";
|
echo "<h3 id='inherited'>" . lang('Inherited tables') . "</h3>\n";
|
||||||
echo "<ul>\n";
|
tables_links($inherited);
|
||||||
foreach ($inherited as $val) {
|
|
||||||
echo "<li><a href='" . h(ME . "table=" . urlencode($val)) . "'>" . h($val) . "</a>\n";
|
|
||||||
}
|
|
||||||
echo "</ul>\n";
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user