1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-16 19:44:00 +02:00

Use ALTER VIEW and don't use temporary object if changing name

This commit is contained in:
Jakub Vrana
2013-05-13 11:12:28 -07:00
parent 3ed0ce926c
commit 982974fe27
3 changed files with 41 additions and 20 deletions

View File

@@ -4,19 +4,28 @@ $row = $_POST;
if ($_POST && !$error) {
$name = trim($row["name"]);
$temp_name = $name . "_adminer_" . uniqid();
$as = " AS\n$row[select]";
drop_create(
"DROP VIEW " . table($TABLE),
"CREATE VIEW " . table($name) . $as,
"CREATE VIEW " . table($temp_name) . $as,
"DROP VIEW " . table($temp_name),
($_POST["drop"] ? substr(ME, 0, -1) : ME . "table=" . urlencode($name)),
lang('View has been dropped.'),
lang('View has been altered.'),
lang('View has been created.'),
$TABLE
);
$location = ME . "table=" . urlencode($name);
$message = lang('View has been altered.');
if (!$_POST["drop"] && $TABLE == $name && $jush != "sqlite") {
query_redirect(($jush == "mssql" ? "ALTER" : "CREATE OR REPLACE") . " VIEW " . table($name) . $as, $location, $message);
} else {
$temp_name = $name . "_adminer_" . uniqid();
drop_create(
"DROP VIEW " . table($TABLE),
"CREATE VIEW " . table($name) . $as,
"DROP VIEW " . table($name),
"CREATE VIEW " . table($temp_name) . $as,
"DROP VIEW " . table($temp_name),
($_POST["drop"] ? substr(ME, 0, -1) : $location),
lang('View has been dropped.'),
$message,
lang('View has been created.'),
$TABLE,
$name
);
}
}
page_header(($TABLE != "" ? lang('Alter view') : lang('Create view')), $error, array("table" => $TABLE), $TABLE);