Skip to content
Browse files

Respect move and drop column support

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1518 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information...
1 parent 7ee5992 commit da8a1b66b96c900a9cb933279bc3df5e25127d5b jakubvrana committed May 5, 2010
View
2 adminer/drivers/mssql.inc.php
@@ -490,7 +490,7 @@ function show_status() {
}
function support($feature) {
- return ereg('^(trigger)$', $feature); //! view|routine|
+ return ereg('^(trigger|drop_col)$', $feature); //! view|routine|
}
$driver = "mssql";
View
9 adminer/drivers/mysql.inc.php
@@ -790,14 +790,7 @@ function show_status() {
*/
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
View
4 adminer/drivers/pgsql.inc.php
@@ -197,7 +197,7 @@ function count_tables($databases) {
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 @@ function use_sql($database) {
}
function support($feature) {
- return ereg('^(comment|view|routine|trigger)$', $feature);
+ return ereg('^(comment|view|trigger|drop_col)$', $feature); //! routine|
}
$driver = "pgsql";
View
4 adminer/drivers/sqlite.inc.php
@@ -393,7 +393,9 @@ function alter_table($table, $name, $fields, $foreign, $comment, $engine, $colla
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 != "") {
View
19 adminer/include/editing.inc.php
@@ -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;
View
1 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

0 comments on commit da8a1b6

Please sign in to comment.
Something went wrong with that request. Please try again.