PostgreSQL: fix namespace in inheritance links

This commit is contained in:
Inoyatulloh
2026-02-08 03:43:47 +05:00
committed by Jakub Vrana
parent 1879da5ad8
commit 9d1451e659
4 changed files with 9 additions and 7 deletions

View File

@@ -14,6 +14,7 @@
- PostgreSQL: Add schema to sequence and and view export
- PostgreSQL: Fix definition of complex generated columns
- PostgreSQL: Mark unique partial indexes as unique (bug #1172)
- PostgreSQL: fix namespace in inheritance links (bug #1221)
- ClickHouse: Fix offset (bug #1188)
- ClickHouse: Fix list of tables (bug #1176)
- Plugins: Methods showVariables() and showStatus() (bug #1157)

View File

@@ -334,11 +334,11 @@ if (isset($_GET["pgsql"])) {
}
function inheritsFrom(string $table): array {
return get_vals("SELECT relname FROM pg_class JOIN pg_inherits ON inhparent = oid WHERE inhrelid = " . $this->tableOid($table) . " ORDER BY 1");
return get_rows("SELECT relname AS table, nspname AS ns FROM pg_class JOIN pg_inherits ON inhparent = oid JOIN pg_namespace ON relnamespace = pg_namespace.oid WHERE inhrelid = " . $this->tableOid($table) . " ORDER BY 2, 1");
}
function inheritedTables(string $table): array {
return get_vals("SELECT relname FROM pg_inherits JOIN pg_class ON inhrelid = oid WHERE inhparent = " . $this->tableOid($table) . " ORDER BY 1");
return get_rows("SELECT relname AS table, nspname AS ns FROM pg_inherits JOIN pg_class ON inhrelid = oid JOIN pg_namespace ON relnamespace = pg_namespace.oid WHERE inhparent = " . $this->tableOid($table) . " ORDER BY 2, 1");
}
function partitionsInfo(string $table): array {

View File

@@ -215,14 +215,14 @@ abstract class SqlDriver {
}
/** Get tables this table inherits from
* @return list<string>
* @return list<array{table: string, ns: string}>
*/
function inheritsFrom(string $table): array {
return array();
}
/** Get inherited tables
* @return list<string>
* @return list<array{table: string, ns: string}>
*/
function inheritedTables(string $table): array {
return array();

View File

@@ -27,12 +27,13 @@ if ($fields) {
}
/** Print links to tables
* @param list<string> $tables
* @param list<array{table: string, ns: string}> $tables
*/
function tables_links(array $tables): void {
echo "<ul>\n";
foreach ($tables as $table) {
echo "<li><a href='" . h(ME . "table=" . urlencode($table)) . "'>" . h($table) . "</a>";
foreach ($tables as $row) {
$link = preg_replace('~ns=[^&]*~', "ns=" . urlencode($row["ns"]), ME);
echo "<li><a href='" . h($link . "table=" . urlencode($row["table"])) . "'>" . ($row["ns"] != $_GET["ns"] ? "<b>" . h($row["ns"]) . "</b>." : "") . h($row["table"]) . "</a>";
}
echo "</ul>\n";
}