diff --git a/js/tbl_structure.js b/js/tbl_structure.js index d0ef72efaf..d7fb298fdf 100644 --- a/js/tbl_structure.js +++ b/js/tbl_structure.js @@ -108,33 +108,6 @@ AJAX.registerOnload('tbl_structure.js', function () { var $form = $(this); var field_cnt = $form.find('input[name=orig_num_fields]').val(); - /* - * First validate the form; if there is a problem, avoid submitting it - * - * checkTableEditForm() needs a pure element and not a jQuery object, - * this is why we pass $form[0] as a parameter (the jQuery object - * is actually an array of DOM elements) - */ - if (checkTableEditForm($form[0], field_cnt)) { - // OK, form passed validation step - - PMA_prepareForAjaxRequest($form); - if (PMA_checkReservedWordColumns($form)) { - //User wants to submit the form - - // If Collation is changed, Warn and Confirm - if (checkIfConfirmRequired($form, field_cnt)){ - var question = sprintf( - PMA_messages.strChangeColumnCollation, 'http://wiki.phpmyadmin.net/pma/Garbled_data' - ); - $form.PMA_confirm(question, $form.attr('action'), function (url) { - submitForm(); - }); - } else { - submitForm(); - } - } - } function submitForm(){ $msg = PMA_ajaxShowMessage(PMA_messages.strProcessingRequest); @@ -181,6 +154,34 @@ AJAX.registerOnload('tbl_structure.js', function () { } return checkRequired; } + + /* + * First validate the form; if there is a problem, avoid submitting it + * + * checkTableEditForm() needs a pure element and not a jQuery object, + * this is why we pass $form[0] as a parameter (the jQuery object + * is actually an array of DOM elements) + */ + if (checkTableEditForm($form[0], field_cnt)) { + // OK, form passed validation step + + PMA_prepareForAjaxRequest($form); + if (PMA_checkReservedWordColumns($form)) { + //User wants to submit the form + + // If Collation is changed, Warn and Confirm + if (checkIfConfirmRequired($form, field_cnt)){ + var question = sprintf( + PMA_messages.strChangeColumnCollation, 'http://wiki.phpmyadmin.net/pma/Garbled_data' + ); + $form.PMA_confirm(question, $form.attr('action'), function (url) { + submitForm(); + }); + } else { + submitForm(); + } + } + } }); // end change table button "do_save_data" /** diff --git a/libraries/structure.lib.php b/libraries/structure.lib.php index 241e4bcd8c..0c269ae617 100644 --- a/libraries/structure.lib.php +++ b/libraries/structure.lib.php @@ -2596,6 +2596,7 @@ function PMA_updateColumns($db, $table) if (isset($_REQUEST['field_adjust_privileges'][$i]) && ! empty($_REQUEST['field_adjust_privileges'][$i]) + && $_REQUEST['field_orig'][$i] != $_REQUEST['field_name'][$i] ) { $adjust_privileges[$_REQUEST['field_orig'][$i]] = $_REQUEST['field_name'][$i]; } @@ -2644,8 +2645,8 @@ function PMA_updateColumns($db, $table) && $_REQUEST['field_collation'][$i] !== $_REQUEST['field_collation_orig'][$i] ) { $secondary_query = 'ALTER TABLE ' . PMA_Util::backquote($table) - . ' CHANGE ' . PMA_Util::backquote($_REQUEST['field_name'][$i]) - . ' ' . PMA_Util::backquote($_REQUEST['field_name'][$i]) + . ' CHANGE ' . PMA_Util::backquote($_REQUEST['field_orig'][$i]) + . ' ' . PMA_Util::backquote($_REQUEST['field_orig'][$i]) . ' BLOB;'; $GLOBALS['dbi']->query($secondary_query); $changedToBlob[$i] = true; @@ -2799,9 +2800,11 @@ function PMA_adjustColumnPrivileges($db, $table, $adjust_privileges) $changed = true; } - // Finally FLUSH the new privileges - $flushPrivQuery = "FLUSH PRIVILEGES;"; - $GLOBALS['dbi']->query($flushPrivQuery); + if ($changed) { + // Finally FLUSH the new privileges + $flushPrivQuery = "FLUSH PRIVILEGES;"; + $GLOBALS['dbi']->query($flushPrivQuery); + } return $changed; }