Fix bug 3842: create, alter, drop queries were not shown after execution

This commit is contained in:
Atul Pratap Singh 2013-03-21 11:13:43 +05:30
parent 1bb9008f7d
commit f3aa2a3d33
2 changed files with 36 additions and 19 deletions

View File

@ -61,11 +61,16 @@ if (! empty($sql_query)) {
$import_type = 'query';
$format = 'sql';
// refresh left frame on changes in table or db structure
if (preg_match('/^(CREATE|ALTER|DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', $sql_query)) {
// refresh navigation and main panels
if (preg_match('/^(DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', $sql_query)) {
$GLOBALS['reload'] = true;
}
// refresh navigation panel only
if (preg_match('/^(CREATE|ALTER)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', $sql_query)) {
$ajax_reload['reload'] = true;
}
// do a dynamic reload if table is RENAMED
// (by sending the instruction to the AJAX response handler)
if (preg_match('/^RENAME\s+TABLE\s+(.*?)\s+TO\s+(.*?)($|;|\s)/i', $sql_query, $rename_table_names)) {
@ -227,11 +232,15 @@ if (! empty($id_bookmark)) {
);
}
// refresh left frame on changes in table or db structure
if (preg_match('/^(CREATE|ALTER|DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', $import_text)) {
// refresh navigation and main panels
if (preg_match('/^(DROP)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', $import_text)) {
$GLOBALS['reload'] = true;
}
// refresh navigation panel only
if (preg_match('/^(CREATE|ALTER)\s+(VIEW|TABLE|DATABASE|SCHEMA)\s+/i', $import_text)) {
$ajax_reload['reload'] = true;
}
break;
case 1: // bookmarked query that have to be displayed
$import_text = PMA_Bookmark_get($db, $id_bookmark);

View File

@ -253,6 +253,9 @@ AJAX.registerOnload('sql.js', function() {
//
// fade out previous messages, if any
$('div.success, div.sqlquery_message').fadeOut();
if ($('#result_query').length) {
$('#result_query').remove();
}
// show a message that stays on screen
if (typeof data.action_bookmark != 'undefined') {
@ -283,9 +286,27 @@ AJAX.registerOnload('sql.js', function() {
if (typeof data.ajax_reload != 'undefined') {
if (data.ajax_reload.reload) {
PMA_commonParams.set('table', data.ajax_reload.table_name);
PMA_commonActions.refreshMain();
if (data.ajax_reload.table_name) {
PMA_commonParams.set('table', data.ajax_reload.table_name);
PMA_commonActions.refreshMain();
} else {
PMA_reloadNavigation();
}
}
} else if (typeof data.reload != 'undefined') {
// this happens if a USE or DROP command was typed
PMA_commonActions.setDb(data.db);
PMA_commonActions.refreshMain(false, function () {
if ($('#result_query').length) {
$('#result_query').remove();
}
if (data.sql_query) {
$('<div id="result_query"></div>')
.html(data.sql_query)
.prependTo('#page_content');
}
});
PMA_reloadNavigation();
}
$sqlqueryresults.show().trigger('makegrid');
@ -299,19 +320,6 @@ AJAX.registerOnload('sql.js', function() {
}
}
}
// this happens if a USE command was typed
if (typeof data.reload != 'undefined') {
// Unbind the submit event before reloading. See bug #3295529
$("#sqlqueryform.ajax").die('submit');
$form.find('input[name=db]').val(data.db);
// need to regenerate the whole upper part
$form.find('input[name=ajax_request]').remove();
$form.append('<input type="hidden" name="reload" value="true" />');
$.post('db_sql.php', $form.serialize(), function(data) {
$('body').html(data);
}); // end inner post
}
} else if (data.success == false ) {
// show an error message that stays on screen
$('#sqlqueryform').before(data.error);