Speed up alter table
Alter table mysql.user takes 0.9 instead of 1.5 seconds.
This commit is contained in:
parent
2761f44cf4
commit
ea1ff7e902
|
@ -266,7 +266,7 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
echo script("qsl('tbody').onkeydown = editingKeydown;");
|
echo script("mixin(qsl('tbody'), {onclick: editingClick, onkeydown: editingKeydown});");
|
||||||
foreach ($fields as $i => $field) {
|
foreach ($fields as $i => $field) {
|
||||||
$i++;
|
$i++;
|
||||||
$orig = $field[($_POST ? "orig" : "field")];
|
$orig = $field[($_POST ? "orig" : "field")];
|
||||||
|
@ -279,18 +279,18 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra
|
||||||
<?php edit_type("fields[$i]", $field, $collations, $foreign_keys); ?>
|
<?php edit_type("fields[$i]", $field, $collations, $foreign_keys); ?>
|
||||||
<?php if ($type == "TABLE") { ?>
|
<?php if ($type == "TABLE") { ?>
|
||||||
<td><?php echo checkbox("fields[$i][null]", 1, $field["null"], "", "", "block", "label-null"); ?>
|
<td><?php echo checkbox("fields[$i][null]", 1, $field["null"], "", "", "block", "label-null"); ?>
|
||||||
<td><label class="block"><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked<?php } ?> aria-labelledby="label-ai"><?php echo script("qsl('input').onclick = function () { var field = this.form['fields[' + this.value + '][field]']; if (!field.value) { field.value = 'id'; field.oninput(); } }"); ?></label><td><?php
|
<td><label class="block"><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked<?php } ?> aria-labelledby="label-ai"></label><td><?php
|
||||||
echo checkbox("fields[$i][has_default]", 1, $field["has_default"], "", "", "", "label-default"); ?><input name="fields[<?php echo $i; ?>][default]" value="<?php echo h($field["default"]); ?>" aria-labelledby="label-default"><?php echo script("qsl('input').oninput = function () { this.previousSibling.checked = true; }", ""); ?>
|
echo checkbox("fields[$i][has_default]", 1, $field["has_default"], "", "", "", "label-default"); ?><input name="fields[<?php echo $i; ?>][default]" value="<?php echo h($field["default"]); ?>" aria-labelledby="label-default"><?php echo script("qsl('input').oninput = function () { this.previousSibling.checked = true; }", ""); ?>
|
||||||
<?php echo (support("comment") ? "<td" . ($comments ? "" : " class='hidden'") . "><input name='fields[$i][comment]' value='" . h($field["comment"]) . "' maxlength='" . (min_version(5.5) ? 1024 : 255) . "' aria-labelledby='label-comment'>" : ""); ?>
|
<?php echo (support("comment") ? "<td" . ($comments ? "" : " class='hidden'") . "><input name='fields[$i][comment]' value='" . h($field["comment"]) . "' maxlength='" . (min_version(5.5) ? 1024 : 255) . "' aria-labelledby='label-comment'>" : ""); ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php
|
<?php
|
||||||
echo "<td>";
|
echo "<td>";
|
||||||
echo (support("move_col") ?
|
echo (support("move_col") ?
|
||||||
"<input type='image' class='icon' name='add[$i]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'> " . script("qsl('input').onclick = partial(editingAddRow, 1);", "")
|
"<input type='image' class='icon' name='add[$i]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'> "
|
||||||
. "<input type='image' class='icon' name='up[$i]' src='../adminer/static/up.gif' alt='↑' title='" . lang('Move up') . "'> " . script("qsl('input').onclick = partial(editingMoveRow, 1);", "")
|
. "<input type='image' class='icon' name='up[$i]' src='../adminer/static/up.gif' alt='↑' title='" . lang('Move up') . "'> "
|
||||||
. "<input type='image' class='icon' name='down[$i]' src='../adminer/static/down.gif' alt='↓' title='" . lang('Move down') . "'> " . script("qsl('input').onclick = partial(editingMoveRow, 0);", "")
|
. "<input type='image' class='icon' name='down[$i]' src='../adminer/static/down.gif' alt='↓' title='" . lang('Move down') . "'> "
|
||||||
: "");
|
: "");
|
||||||
echo ($orig == "" || support("drop_col") ? "<input type='image' class='icon' name='drop_col[$i]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "'>" . script("qsl('input').onclick = partial(editingRemoveRow, 'fields\$1[field]');") : "");
|
echo ($orig == "" || support("drop_col") ? "<input type='image' class='icon' name='drop_col[$i]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "'>" : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,42 @@ function idfEscape(s) {
|
||||||
return s.replace(/`/, '``');
|
return s.replace(/`/, '``');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Handle clicks on fields editing
|
||||||
|
* @param MouseEvent
|
||||||
|
* @return boolean false to cancel action
|
||||||
|
*/
|
||||||
|
function editingClick(event) {
|
||||||
|
var el = getTarget(event);
|
||||||
|
if (!isTag(el, 'input')) {
|
||||||
|
el = parentTag(target, 'label');
|
||||||
|
el = el && qs('input', el);
|
||||||
|
}
|
||||||
|
if (el) {
|
||||||
|
var name = el.name;
|
||||||
|
if (/^add\[/.test(name)) {
|
||||||
|
editingAddRow.call(el, 1);
|
||||||
|
} else if (/^up\[/.test(name)) {
|
||||||
|
editingMoveRow.call(el, 1);
|
||||||
|
} else if (/^down\[/.test(name)) {
|
||||||
|
editingMoveRow.call(el);
|
||||||
|
} else if (/^drop_col\[/.test(name)) {
|
||||||
|
editingRemoveRow.call(el, 'fields\$1[field]');
|
||||||
|
} else {
|
||||||
|
if (name == 'auto_increment_col') {
|
||||||
|
var field = el.form['fields[' + el.value + '][field]'];
|
||||||
|
if (!field.value) {
|
||||||
|
field.value = 'id';
|
||||||
|
field.oninput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Detect foreign key
|
/** Detect foreign key
|
||||||
* @this HTMLInputElement
|
* @this HTMLInputElement
|
||||||
*/
|
*/
|
||||||
|
@ -269,7 +305,7 @@ function editingAddRow(focus) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Remove table row for field
|
/** Remove table row for field
|
||||||
* @param string
|
* @param string regular expression replacement
|
||||||
* @return boolean false
|
* @return boolean false
|
||||||
* @this HTMLInputElement
|
* @this HTMLInputElement
|
||||||
*/
|
*/
|
||||||
|
@ -281,16 +317,16 @@ function editingRemoveRow(name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Move table row for field
|
/** Move table row for field
|
||||||
* @param boolean direction to move row, true for up or false for down
|
* @param [boolean]
|
||||||
* @return boolean false for success
|
* @return boolean false for success
|
||||||
* @this HTMLInputElement
|
* @this HTMLInputElement
|
||||||
*/
|
*/
|
||||||
function editingMoveRow(dir){
|
function editingMoveRow(up){
|
||||||
var row = parentTag(this, 'tr');
|
var row = parentTag(this, 'tr');
|
||||||
if (!('nextElementSibling' in row)) {
|
if (!('nextElementSibling' in row)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
row.parentNode.insertBefore(row, dir
|
row.parentNode.insertBefore(row, up
|
||||||
? row.previousElementSibling
|
? row.previousElementSibling
|
||||||
: row.nextElementSibling ? row.nextElementSibling.nextElementSibling : row.parentNode.firstChild);
|
: row.nextElementSibling ? row.nextElementSibling.nextElementSibling : row.parentNode.firstChild);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
Adminer 4.6.2-dev:
|
Adminer 4.6.2-dev:
|
||||||
Semi-transparent border on table actions
|
Semi-transparent border on table actions
|
||||||
Shorten JSON values in select (bug #594)
|
Shorten JSON values in select (bug #594)
|
||||||
|
Speed up alter table (regression from 4.4.0)
|
||||||
PostgreSQL: Fix exporting string default values
|
PostgreSQL: Fix exporting string default values
|
||||||
PostgreSQL: Fix exporting sequences in PostgreSQL 10
|
PostgreSQL: Fix exporting sequences in PostgreSQL 10
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue