Display error on invalid alter table and view pages

This commit is contained in:
Jakub Vrana 2013-06-24 09:08:26 -07:00
parent 2e32bf1f97
commit e51640eb98
3 changed files with 15 additions and 8 deletions

View file

@ -9,10 +9,13 @@ foreach ($referencable_primary as $table_name => $field) {
}
$orig_fields = array();
$orig_status = array();
$table_status = array();
if ($TABLE != "") {
$orig_fields = fields($TABLE);
$orig_status = table_status($TABLE);
$table_status = table_status($TABLE);
if (!$table_status) {
$error = lang('No tables.');
}
}
$row = $_POST;
@ -80,7 +83,7 @@ if ($_POST && !process_fields($row["fields"]) && !$error) {
? " (" . implode(",", $partitions) . "\n)"
: ($row["partitions"] ? " PARTITIONS " . (+$row["partitions"]) : "")
);
} elseif (support("partitioning") && ereg("partitioned", $orig_status["Create_options"])) {
} elseif (support("partitioning") && ereg("partitioned", $table_status["Create_options"])) {
$partitioning .= "\nREMOVE PARTITIONING";
}
@ -97,8 +100,8 @@ if ($_POST && !process_fields($row["fields"]) && !$error) {
($jush == "sqlite" && ($use_all_fields || $foreign) ? $all_fields : $fields),
$foreign,
$row["Comment"],
($row["Engine"] && $row["Engine"] != $orig_status["Engine"] ? $row["Engine"] : ""),
($row["Collation"] && $row["Collation"] != $orig_status["Collation"] ? $row["Collation"] : ""),
($row["Engine"] && $row["Engine"] != $table_status["Engine"] ? $row["Engine"] : ""),
($row["Collation"] && $row["Collation"] != $table_status["Collation"] ? $row["Collation"] : ""),
($row["Auto_increment"] != "" ? +$row["Auto_increment"] : ""),
$partitioning
));
@ -115,7 +118,7 @@ if (!$_POST) {
);
if ($TABLE != "") {
$row = $orig_status;
$row = $table_status;
$row["name"] = $TABLE;
$row["fields"] = array();
if (!$_GET["auto_increment"]) { // don't prefill by original Auto_increment for the sake of performance and not reusing deleted ids

View file

@ -28,12 +28,15 @@ if ($_POST && !$error) {
}
}
page_header(($TABLE != "" ? lang('Alter view') : lang('Create view')), $error, array("table" => $TABLE), $TABLE);
if (!$_POST && $TABLE != "") {
$row = view($TABLE);
$row["name"] = $TABLE;
if (!$error) {
$error = $connection->error;
}
}
page_header(($TABLE != "" ? lang('Alter view') : lang('Create view')), $error, array("table" => $TABLE), $TABLE);
?>
<form action="" method="post">

View file

@ -8,6 +8,7 @@ Verify UTF-8 encoding of CSV import
Notify user about expired master password for permanent login
Send 404 for invalid database and schema
Fix title and links on invalid table pages
Display error on invalid alter table and view pages
MySQL: Speed up updating rows without numeric or UTF-8 primary key
PostgreSQL: Fix detecting oid column in PDO
PostgreSQL: Handle timestamp types (bug #3614086)