]> git.joonet.de Git - adminer.git/commitdiff
Respect move and drop column support
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Wed, 5 May 2010 16:27:39 +0000 (16:27 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Wed, 5 May 2010 16:27:39 +0000 (16:27 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1518 7c3ca157-0c34-0410-bff1-cbf682f78f5c

adminer/drivers/mssql.inc.php
adminer/drivers/mysql.inc.php
adminer/drivers/pgsql.inc.php
adminer/drivers/sqlite.inc.php
adminer/include/editing.inc.php
todo.txt

index bf980807e11db43e9726c09f5564fa24b6bfa8e7..c57af4164b08aede63e9e95b323ad6936ab3fd63 100644 (file)
@@ -490,7 +490,7 @@ WHERE sys1.xtype = 'TR' AND sys2.name = " . $connection->quote($table)
        }
 
        function support($feature) {
-               return ereg('^(trigger)$', $feature); //! view|routine|
+               return ereg('^(trigger|drop_col)$', $feature); //! view|routine|
        }
        
        $driver = "mssql";
index b8d9a4cbfd432f36380905d14e10761b8168acb6..c0dc2e41120956c63eb9678d6c52aff99b34541f 100644 (file)
@@ -790,14 +790,7 @@ if (!defined("DRIVER")) {
        */
        function support($feature) {
                global $connection;
-               $features = array(
-                       "view" => ($connection->server_info >= 5),
-                       "routine" => ($connection->server_info >= 5),
-                       "trigger" => ($connection->server_info >= 5),
-                       "event" => ($connection->server_info >= 5.1),
-                       "partitioning" => ($connection->server_info >= 5.1),
-               );
-               return (isset($features[$feature]) ? $features[$feature] : true);
+               return ($connection->server_info >= 5.1 || ($connection->server_info >= 5 && !ereg("event|partitioning")) || !ereg("view|routine|trigger"));
        }
 
        $driver = "sql"; ///< @var string JUSH identifier
index 4b6cc42961328656535b6cbd8573851953dc3ddc..eaf3ee03370d58d0c041f3205aded55156de7d79 100644 (file)
@@ -197,7 +197,7 @@ if (isset($_GET["pgsql"])) {
        function table_status($name = "") {
                global $connection;
                $return = array();
-               $result = $connection->query("SELECT relname AS \"Name\", CASE relkind WHEN 'r' THEN '' ELSE 'view' END AS \"Engine\", pg_relation_size(oid) AS \"Data_length\", pg_catalog.obj_description(oid, 'pg_class') AS \"Comment\"
+               $result = $connection->query("SELECT relname AS \"Name\", CASE relkind WHEN 'r' THEN '' ELSE 'view' END AS \"Engine\", pg_relation_size(oid) AS \"Data_length\", pg_total_relation_size(oid) - pg_relation_size(oid) AS \"Index_length\", pg_catalog.obj_description(oid, 'pg_class') AS \"Comment\"
 FROM pg_catalog.pg_class
 WHERE relkind IN ('r','v')
 AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = current_schema())"
@@ -457,7 +457,7 @@ WHERE tc.constraint_type = 'FOREIGN KEY' AND tc.table_name = " . $connection->qu
        }
        
        function support($feature) {
-               return ereg('^(comment|view|routine|trigger)$', $feature);
+               return ereg('^(comment|view|trigger|drop_col)$', $feature); //! routine|
        }
        
        $driver = "pgsql";
index 58b5f026338d43a86e5fde79f682c74095b75333..028b0e5d4034244a47f38b49e90cd266f65014c8 100644 (file)
@@ -393,7 +393,9 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
                global $connection;
                $alter = array();
                foreach ($fields as $field) {
-                       $alter[] = ($table != "" && $field[0] == "" ? "ADD " : "  ") . implode("", $field[1]);
+                       if ($field[1]) {
+                               $alter[] = ($table != "" && $field[0] == "" ? "ADD " : "  ") . implode("", $field[1]);
+                       }
                }
                $alter = array_merge($alter, $foreign);
                if ($table != "") {
index 6aa71835c95f342c50c10e2fc7c65b80958f8298..ce2f1d6c14fea77323b4d30f5055fc02933bbc68 100644 (file)
@@ -203,16 +203,17 @@ function edit_fields($fields, $collations, $type = "TABLE", $allowed = 0, $forei
 <td class="hidden"><?php echo lang('Default values'); ?>
 <?php echo (support("comment") ? "<td" . ($comments ? "" : " class='hidden'") . ">" . lang('Comment') : ""); ?>
 <?php } ?>
-<td><?php echo "<input type='image' name='add[0]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'>"; ?><script type="text/javascript">row_count = <?php echo count($fields); ?>;</script>
+<td><?php echo "<input type='image' name='add[" . (support("move_col") ? 0 : count($fields)) . "]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'>"; ?><script type="text/javascript">row_count = <?php echo count($fields); ?>;</script>
 </thead>
 <?php
        foreach ($fields as $i => $field) {
                $i++;
-               $display = (isset($_POST["add"][$i-1]) || (isset($field["field"]) && !$_POST["drop_col"][$i]));
+               $orig = $field[($_POST ? "orig" : "field")];
+               $display = (isset($_POST["add"][$i-1]) || (isset($field["field"]) && !$_POST["drop_col"][$i])) && (support("drop_col") || $orig == "");
                ?>
 <tr<?php echo ($display ? "" : " style='display: none;'"); ?>>
 <?php echo ($type == "PROCEDURE" ? "<td>" . html_select("fields[$i][inout]", $inout, $field["inout"]) : ""); ?>
-<th><?php if ($display) { ?><input name="fields[<?php echo $i; ?>][field]" value="<?php echo h($field["field"]); ?>" onchange="<?php echo ($field["field"] != "" || count($fields) > 1 ? "" : "editingAddRow(this, $allowed); "); ?>editingNameChange(this);" maxlength="64"><?php } ?><input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo h($field[($_POST ? "orig" : "field")]); ?>">
+<th><?php if ($display) { ?><input name="fields[<?php echo $i; ?>][field]" value="<?php echo h($field["field"]); ?>" onchange="<?php echo ($field["field"] != "" || count($fields) > 1 ? "" : "editingAddRow(this, $allowed); "); ?>editingNameChange(this);" maxlength="64"><?php } ?><input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo h($orig); ?>">
 <?php edit_type("fields[$i]", $field, $collations, $foreign_keys); ?>
 <?php if ($type == "TABLE") { ?>
 <td><?php echo checkbox("fields[$i][null]", 1, $field["null"]); ?>
@@ -221,11 +222,13 @@ function edit_fields($fields, $collations, $type = "TABLE", $allowed = 0, $forei
 <?php echo (support("comment") ? "<td" . ($comments ? "" : " class='hidden'") . "><input name='fields[$i][comment]' value='" . h($field["comment"]) . "' maxlength='255'>" : ""); ?>
 <?php } ?>
 <?php
-               //! hide operations not supported by the driver - column change, adding column not at the end, drop column, ...
-               echo "<td><input type='image' name='add[$i]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "' onclick='return !editingAddRow(this, $allowed, 1);'>";
-               echo "&nbsp;<input type='image' name='drop_col[$i]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "' onclick='return !editingRemoveRow(this);'>";
-               echo "&nbsp;<input type='image' name='up[$i]' src='../adminer/static/up.gif' alt='^' title='" . lang('Move up') . "'>";
-               echo "&nbsp;<input type='image' name='down[$i]' src='../adminer/static/down.gif' alt='v' title='" . lang('Move down') . "'>";
+               echo "<td>";
+               echo (support("move_col") ?
+                       "<input type='image' name='add[$i]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "' onclick='return !editingAddRow(this, $allowed, 1);'>&nbsp;"
+                       . "<input type='image' name='up[$i]' src='../adminer/static/up.gif' alt='^' title='" . lang('Move up') . "'>&nbsp;"
+                       . "<input type='image' name='down[$i]' src='../adminer/static/down.gif' alt='v' title='" . lang('Move down') . "'>&nbsp;"
+               : "");
+               echo ($orig == "" || support("drop_col") ? "<input type='image' name='drop_col[$i]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "' onclick='return !editingRemoveRow(this);'>" : "");
                echo "\n";
        }
        return $comments;
index 41b200870e39dcaa371623db12deece9b75ce17f..4beb904cea23ba564de88a4a4228eb52061809cf 100644 (file)
--- a/todo.txt
+++ b/todo.txt
@@ -37,7 +37,6 @@ Users - SELECT * FROM pg_user
 ORDER BY COUNT(*)
 Table schema - SELECT * FROM pg_namespace, CREATE|ALTER|DROP SCHEMA, SET default_tablespace
 Export - http://www.postgresql.org/docs/8.4/static/functions-info.html
-Table status - http://www.postgresql.org/docs/8.4/static/functions-admin.html
 Column rights - http://www.postgresql.org/docs/8.4/static/functions-info.html
 Dollar terminated string in SQL command
 Move table - ALTER TABLE SET SCHEMA