mirror of
https://github.com/vrana/adminer.git
synced 2025-08-07 23:27:17 +02:00
PostgreSQL: Allow changing materialized views
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
<?php
|
||||
$TABLE = $_GET["view"];
|
||||
$row = $_POST;
|
||||
$orig_type = "VIEW";
|
||||
if ($jush == "pgsql" && $TABLE != "") {
|
||||
$status = table_status($TABLE);
|
||||
$orig_type = strtoupper($status["Engine"]);
|
||||
}
|
||||
|
||||
if ($_POST && !$error) {
|
||||
$name = trim($row["name"]);
|
||||
@@ -8,22 +13,14 @@ if ($_POST && !$error) {
|
||||
$location = ME . "table=" . urlencode($name);
|
||||
$message = lang('View has been altered.');
|
||||
|
||||
if ($_GET["materialized"]) {
|
||||
$type = "MATERIALIZED VIEW";
|
||||
} else {
|
||||
$type = "VIEW";
|
||||
if ($jush == "pgsql") {
|
||||
$status = table_status($name);
|
||||
$type = ($status ? strtoupper($status["Engine"]) : $type);
|
||||
}
|
||||
}
|
||||
$type = ($_POST["materialized"] ? "MATERIALIZED VIEW" : "VIEW");
|
||||
|
||||
if (!$_POST["drop"] && $TABLE == $name && $jush != "sqlite" && $type != "MATERIALIZED VIEW") {
|
||||
if (!$_POST["drop"] && $TABLE == $name && $jush != "sqlite" && $type == "VIEW" && $orig_type == "VIEW") {
|
||||
query_redirect(($jush == "mssql" ? "ALTER" : "CREATE OR REPLACE") . " VIEW " . table($name) . $as, $location, $message);
|
||||
} else {
|
||||
$temp_name = $name . "_adminer_" . uniqid();
|
||||
drop_create(
|
||||
"DROP $type " . table($TABLE),
|
||||
"DROP $orig_type " . table($TABLE),
|
||||
"CREATE $type " . table($name) . $as,
|
||||
"DROP $type " . table($name),
|
||||
"CREATE $type " . table($temp_name) . $as,
|
||||
@@ -41,6 +38,7 @@ if ($_POST && !$error) {
|
||||
if (!$_POST && $TABLE != "") {
|
||||
$row = view($TABLE);
|
||||
$row["name"] = $TABLE;
|
||||
$row["materialized"] = ($orig_type != "VIEW");
|
||||
if (!$error) {
|
||||
$error = error();
|
||||
}
|
||||
@@ -51,6 +49,7 @@ page_header(($TABLE != "" ? lang('Alter view') : lang('Create view')), $error, a
|
||||
|
||||
<form action="" method="post">
|
||||
<p><?php echo lang('Name'); ?>: <input name="name" value="<?php echo h($row["name"]); ?>" maxlength="64" autocapitalize="off">
|
||||
<?php echo (support("materializedview") ? " " . checkbox("materialized", 1, $row["materialized"], lang('Materialized view')) : ""); ?>
|
||||
<p><?php textarea("select", $row["select"]); ?>
|
||||
<p>
|
||||
<input type="submit" value="<?php echo lang('Save'); ?>">
|
||||
|
Reference in New Issue
Block a user