mirror of
https://github.com/vrana/adminer.git
synced 2025-08-12 17:44:07 +02:00
PostgreSQL: Display partition info (bug #1031)
This commit is contained in:
@@ -338,6 +338,19 @@ if (isset($_GET["pgsql"])) {
|
|||||||
return get_vals("SELECT relname FROM pg_inherits JOIN pg_class ON inhrelid = oid WHERE inhparent = " . $this->tableOid($table) . " ORDER BY 1");
|
return get_vals("SELECT relname FROM pg_inherits JOIN pg_class ON inhrelid = oid WHERE inhparent = " . $this->tableOid($table) . " ORDER BY 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function partitionsInfo(string $table): array {
|
||||||
|
$row = connection()->query("SELECT * FROM pg_partitioned_table WHERE partrelid = " . driver()->tableOid($table))->fetch_assoc();
|
||||||
|
if ($row) {
|
||||||
|
$attrs = get_vals("SELECT attname FROM pg_attribute WHERE attrelid = $row[partrelid] AND attnum IN (" . str_replace(" ", ", ", $row["partattrs"]) . ")"); //! ordering
|
||||||
|
$by = array('h' => 'HASH', 'l' => 'LIST', 'r' => 'RANGE');
|
||||||
|
return array(
|
||||||
|
"partition_by" => $by[$row["partstrat"]],
|
||||||
|
"partition" => implode(", ", array_map('Adminer\idf_escape', $attrs)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
function tableOid(string $table): string {
|
function tableOid(string $table): string {
|
||||||
return "(SELECT oid FROM pg_class WHERE relnamespace = $this->nsOid AND relname = " . q($table) . " AND relkind IN ('r', 'm', 'v', 'f', 'p'))";
|
return "(SELECT oid FROM pg_class WHERE relnamespace = $this->nsOid AND relname = " . q($table) . " AND relkind IN ('r', 'm', 'v', 'f', 'p'))";
|
||||||
}
|
}
|
||||||
@@ -943,12 +956,9 @@ AND typelem = 0"
|
|||||||
}
|
}
|
||||||
$return .= implode(",\n ", $return_parts) . "\n)";
|
$return .= implode(",\n ", $return_parts) . "\n)";
|
||||||
|
|
||||||
$table_oid = driver()->tableOid($status['Name']);
|
$partition = driver()->partitionsInfo($status['Name']);
|
||||||
$row = connection()->query("SELECT * FROM pg_partitioned_table WHERE partrelid = $table_oid")->fetch_assoc();
|
if ($partition) {
|
||||||
if ($row) {
|
$return .= "\nPARTITION BY $partition[partition_by]($partition[partition])";
|
||||||
$attrs = get_vals("SELECT attname FROM pg_attribute WHERE attrelid = $row[partrelid] AND attnum IN (" . str_replace(" ", ", ", $row["partattrs"]) . ")"); //! ordering
|
|
||||||
$by = array('h' => 'HASH', 'l' => 'LIST', 'r' => 'RANGE');
|
|
||||||
$return .= "\nPARTITION BY $by[partstrat](" . implode(", ", array_map('Adminer\idf_escape', $attrs)) . ")";
|
|
||||||
}
|
}
|
||||||
//! parse pg_class.relpartbound to create PARTITION OF
|
//! parse pg_class.relpartbound to create PARTITION OF
|
||||||
|
|
||||||
|
@@ -195,7 +195,6 @@ Lang::$translations = array(
|
|||||||
'Partition name' => 'Název oddílu',
|
'Partition name' => 'Název oddílu',
|
||||||
'Values' => 'Hodnoty',
|
'Values' => 'Hodnoty',
|
||||||
'Inherits from' => 'Zděděná z',
|
'Inherits from' => 'Zděděná z',
|
||||||
'Inherited tables' => 'Zděděné tabulky',
|
|
||||||
|
|
||||||
'View' => 'Pohled',
|
'View' => 'Pohled',
|
||||||
'Materialized view' => 'Materializovaný pohled',
|
'Materialized view' => 'Materializovaný pohled',
|
||||||
|
@@ -196,7 +196,6 @@ Lang::$translations = array(
|
|||||||
'Partition name' => 'Nazwa partycji',
|
'Partition name' => 'Nazwa partycji',
|
||||||
'Values' => 'Wartości',
|
'Values' => 'Wartości',
|
||||||
'Inherits from' => 'Dziedziczy po',
|
'Inherits from' => 'Dziedziczy po',
|
||||||
'Inherited tables' => 'Tabele dziedziczone',
|
|
||||||
|
|
||||||
'View' => 'Perspektywa',
|
'View' => 'Perspektywa',
|
||||||
'Materialized view' => 'Zmaterializowana perspektywa',
|
'Materialized view' => 'Zmaterializowana perspektywa',
|
||||||
|
@@ -197,7 +197,6 @@ Lang::$translations = array(
|
|||||||
'Partition name' => 'Xx',
|
'Partition name' => 'Xx',
|
||||||
'Values' => 'Xx',
|
'Values' => 'Xx',
|
||||||
'Inherits from' => 'Xx',
|
'Inherits from' => 'Xx',
|
||||||
'Inherited tables' => 'Xx',
|
|
||||||
|
|
||||||
'View' => 'Xx',
|
'View' => 'Xx',
|
||||||
'Materialized view' => 'Xx',
|
'Materialized view' => 'Xx',
|
||||||
|
@@ -110,6 +110,10 @@ 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='partitions'>" . lang('Partitions') . "</h3>\n";
|
||||||
|
$partition = driver()->partitionsInfo($TABLE);
|
||||||
|
if ($partition) {
|
||||||
|
echo "<p><code class='jush-" . JUSH . "'>BY " . h("$partition[partition_by]($partition[partition])") . "</code>\n";
|
||||||
|
}
|
||||||
tables_links($inherited);
|
tables_links($inherited);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user