]> git.joonet.de Git - adminer.git/commitdiff
Driver specific view detection
authorJakub Vrana <jakub@vrana.cz>
Thu, 27 May 2010 11:31:08 +0000 (13:31 +0200)
committerJakub Vrana <jakub@vrana.cz>
Thu, 27 May 2010 11:33:09 +0000 (13:33 +0200)
adminer/db.inc.php
adminer/drivers/mssql.inc.php
adminer/drivers/mysql.inc.php
adminer/drivers/oracle.inc.php
adminer/drivers/pgsql.inc.php
adminer/drivers/sqlite.inc.php
adminer/dump.inc.php
adminer/include/adminer.inc.php
adminer/table.inc.php

index e7251933805124c65af18a146022ececdd04abd8..89b69b8aaa6ab449d76c950a22db2afe3a4d0ac8 100644 (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";
                                }
index 5d3902d53eedcf1fa3e69e0f0cf5e3d061fa4a54..d14f5d3701e6b37f1d4c5b4015de4253c15fad97 100644 (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;
        }
index aca228d6e3bb33e8c53bd46560a2264a21ee7c2c..1ca1cca3abe77b6136f0850c5eff27d6c93f48b7 100644 (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
index 6fbf49aec94f692e8622a71d337cb3eb31476bf3..3635ef98764cbd5e4b22c0d994e4abacd5680618 100644 (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;
        }
index 3ff313f1045f9c787de3702653337f28d5b44b8f..4255144b1ba9e4ec6906ab60483c2ea0ada5861e 100644 (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;
        }
index fa66ff6764d88990bff42eb265e6f77a29a911c1..ddc989b6c42da90c17115e94b0df42168b8903a2 100644 (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')");
index 17d147734d3990be6e57524ae5d9b093d9e527bf..46bd535767bae6868146d87fb32ce5154ed45c78 100644 (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";
index f2466c08c65271452df426c5dd754a9a75b3d228..d52d4b829ae6476c6314bb5820596853df3df21e 100644 (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');
index 0c4a0c58070a279fe941094cbb80aef73055826d..30a2f234221b9e83e5fbbcf6ff2e42695fe64fd4 100644 (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) {