Driver specific view detection

This commit is contained in:
Jakub Vrana 2010-05-27 13:31:08 +02:00
parent fe3d395912
commit da6f1f850b
9 changed files with 30 additions and 7 deletions

View file

@ -165,7 +165,7 @@ if ($_GET["ns"] !== "") {
foreach ($table_status as $row) {
$id = addcslashes($row["Name"], "\\'/");
echo "setHtml('Comment-$id', '" . nbsp($row["Comment"]) . "');\n";
if (!eregi("view", $row["Engine"])) {
if (!is_view($row)) {
foreach (array("Engine", "Collation") as $key) {
echo "setHtml('$key-$id', '" . nbsp($row[$key]) . "');\n";
}

View file

@ -304,6 +304,10 @@ if (isset($_GET["mssql"])) {
return $return;
}
function is_view($table_status) {
return $table_status["Engine"] == "VIEW";
}
function fk_support($table_status) {
return true;
}

View file

@ -359,7 +359,6 @@ if (!defined("DRIVER")) {
$row["Comment"] = preg_replace('~(?:(.+); )?InnoDB free: .*~', '\\1', $row["Comment"]);
}
if (!isset($row["Rows"])) {
$row["Engine"] = "VIEW";
$row["Comment"] = "";
}
if ($name != "") {
@ -370,6 +369,14 @@ if (!defined("DRIVER")) {
return $return;
}
/** Find out whether the identifier is view
* @param array
* @return bool
*/
function is_view($table_status) {
return !isset($table_status["Rows"]);
}
/** Check if table supports foreign keys
* @param array result of table_status
* @return bool

View file

@ -202,6 +202,10 @@ UNION SELECT view_name, 'view' FROM user_views" . ($name != "" ? " WHERE view_na
return $return;
}
function is_view($table_status) {
return $table_status["Engine"] == "view";
}
function fk_support($table_status) {
return true;
}

View file

@ -213,6 +213,10 @@ AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = current_schema(
return ($name != "" ? $return[$name] : $return);
}
function is_view($table_status) {
return $table_status["Engine"] == "view";
}
function fk_support($table_status) {
return true;
}

View file

@ -262,6 +262,10 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
return ($name != "" ? $return[$name] : $return);
}
function is_view($table_status) {
return $table_status["Engine"] == "view";
}
function fk_support($table_status) {
global $connection;
return !$connection->result("SELECT sqlite_compileoption_used('OMIT_FOREIGN_KEY')");

View file

@ -72,7 +72,7 @@ SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
$table = (DB == "" || in_array($row["Name"], (array) $_POST["tables"]));
$data = (DB == "" || in_array($row["Name"], (array) $_POST["data"]));
if ($table || $data) {
if (isset($row["Engine"])) {
if (!is_view($row)) {
if ($ext == "tar") {
ob_start();
}
@ -197,7 +197,7 @@ if (DB != "") {
$prefix = ereg_replace("_.*", "", $name);
$checked = ($TABLE == "" || $TABLE == (substr($TABLE, -1) == "%" ? "$prefix%" : $name)); //! % may be part of table name
$print = "<tr><td>" . checkbox("tables[]", $name, $checked, $name, "formUncheck('check-tables');");
if (eregi("view", $row["Engine"])) {
if (is_view($row)) {
$views .= "$print\n";
} else {
echo "$print<td align='right'><label>" . ($row["Engine"] == "InnoDB" && $row["Rows"] ? "~ " : "") . $row["Rows"] . checkbox("data[]", $name, $checked, "", "formUncheck('check-data');") . "</label>\n";

View file

@ -86,7 +86,7 @@ document.getElementById('username').focus();
function selectLinks($tableStatus, $set = "") {
echo '<p class="tabs">';
$links = array("select" => lang('Select data'), "table" => lang('Show structure'));
if (eregi("view", $tableStatus["Engine"])) {
if (is_view($tableStatus)) {
$links["view"] = lang('Alter view');
} else {
$links["create"] = lang('Alter table');

View file

@ -6,7 +6,7 @@ if (!$fields) {
}
$table_status = ($fields ? table_status($TABLE) : array());
page_header(($fields && $table_status["Engine"] == "VIEW" ? lang('View') : lang('Table')) . ": " . h($TABLE), $error);
page_header(($fields && is_view($table_status) ? lang('View') : lang('Table')) . ": " . h($TABLE), $error);
$adminer->selectLinks($table_status);
if ($fields) {
@ -20,7 +20,7 @@ if ($fields) {
}
echo "</table>\n";
if ($table_status["Engine"] != "VIEW") {
if (is_view($table_status)) {
echo "<h3>" . lang('Indexes') . "</h3>\n";
$indexes = indexes($TABLE);
if ($indexes) {