From 1b7b9673ac84cccfa1a9c42e65e7a283697dfe46 Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Tue, 20 Jun 2006 17:58:14 +0000 Subject: [PATCH] bug #1490556 Request-URI Too Large --- ChangeLog | 2 ++ js/querywindow.js | 38 ++++++++++++++++++++++++++++---- libraries/common.lib.php | 6 ++--- libraries/sql_query_form.lib.php | 11 +++++++++ 4 files changed, 50 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index a1a846388..c16ade80d 100755 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,8 @@ $Source$ * themes/*/css/theme_right.css.php: bug #1449845 Nowrap in character sets * libraries/common.lib.php::PMA_linkOrButton(): did not recognize hard coded & when ; is set as url separator in php + * js/querywindow.js, libraries/common.lib.php, + libraries/sql_query_form.lib.php: bug #1490556 Request-URI Too Large 2006-06-15 Marc Delisle * libraries/sql_query_form.lib.php: Delimiter only if MySQL supports it diff --git a/js/querywindow.js b/js/querywindow.js index b46d8514a..6623d44cf 100644 --- a/js/querywindow.js +++ b/js/querywindow.js @@ -1,5 +1,13 @@ +/** + * holds the browser query window + */ var querywindow = ''; +/** + * holds the query to be load from a new query window + */ +var query_to_load = ''; + /** * sets current selected db * @@ -198,8 +206,19 @@ function reload_querywindow( db, table, sql_query ) { } } +/** + * brings query window to front and inserts query to be edited + */ function focus_querywindow( sql_query ) { - if ( querywindow && !querywindow.closed && querywindow.location) { + /* if ( querywindow && !querywindow.closed && querywindow.location) { */ + if ( !querywindow || querywindow.closed || !querywindow.location) { + // we need first to open the window and cannot pass the query with it + // as we dont know if the query exceeds max url length + /* url = 'querywindow.php?' + common_query + '&db=' + db + '&table=' + table + '&sql_query=SELECT * FROM'; */ + query_to_load = sql_query; + open_querywindow(); + insertQuery(0); + } else { //var querywindow = querywindow; if ( querywindow.document.querywindow.querydisplay_tab != 'sql' ) { querywindow.document.querywindow.querydisplay_tab.value = "sql"; @@ -209,10 +228,21 @@ function focus_querywindow( sql_query ) { } else { querywindow.focus(); } - } else { - url = 'querywindow.php?' + common_query + '&db=' + db + '&table=' + table + '&sql_query=' + sql_query; - open_querywindow( url ); } + return true; +} + +/** + * inserts query string into query window textarea + * called from script tag in querywindow + */ +function insertQuery() { + if (query_to_load != '' && querywindow.document && querywindow.document.getElementById && querywindow.document.getElementById('sqlquery')) { + querywindow.document.getElementById('sqlquery').value = query_to_load; + query_to_load = ''; + return true; + } + return false; } function open_querywindow( url ) { diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 9f3508195..564a0b2b3 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -1330,8 +1330,8 @@ if (!defined('PMA_MINIMUM_COMMON')) { $a_string = str_replace('\\', '\\\\', $a_string); $a_string = str_replace('\'', '\\\'', $a_string); $a_string = str_replace('#', '\\#', $a_string); - $a_string = str_replace("\012", '\\\\n', $a_string); - $a_string = str_replace("\015", '\\\\r', $a_string); + $a_string = str_replace("\012", '\n', $a_string); + $a_string = str_replace("\015", '\r', $a_string); } return (($add_backquotes) ? PMA_backquote($a_string) : $a_string); @@ -1556,7 +1556,7 @@ window.parent.updateTableTitle('', '' . "\n"; + if ($is_querywindow) { + ?> + +