mirror of
https://github.com/vrana/adminer.git
synced 2025-08-08 15:47:00 +02:00
Respect move and drop column support
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1518 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
@@ -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";
|
||||
|
@@ -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
|
||||
|
@@ -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";
|
||||
|
@@ -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 != "") {
|
||||
|
@@ -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 " <input type='image' name='drop_col[$i]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "' onclick='return !editingRemoveRow(this);'>";
|
||||
echo " <input type='image' name='up[$i]' src='../adminer/static/up.gif' alt='^' title='" . lang('Move up') . "'>";
|
||||
echo " <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);'> "
|
||||
. "<input type='image' name='up[$i]' src='../adminer/static/up.gif' alt='^' title='" . lang('Move up') . "'> "
|
||||
. "<input type='image' name='down[$i]' src='../adminer/static/down.gif' alt='v' title='" . lang('Move down') . "'> "
|
||||
: "");
|
||||
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;
|
||||
|
1
todo.txt
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
|
||||
|
Reference in New Issue
Block a user