From e002e96546599ef34bf20a6e3924d11484bac2a6 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Wed, 13 Nov 2002 18:20:00 +0000 Subject: [PATCH] bug 636563 --- ChangeLog | 2 ++ libraries/common.lib.php3 | 2 +- libraries/sqlparser.lib.php3 | 21 +++++++++++++++------ sql.php3 | 10 +++++----- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3a8680e64..d4211c6e8 100755 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ $Source$ 2002-11-13 Marc Delisle * libraries/sqlparser.lib.php3: bug 636575 (unquoted identifiers) + * libraries/sqlparser.lib.php3, libraries/common.lib.php3, sql.php3: + bug 636563 undefined variable when deleting a row 2002-11-11 Alexander M. Turek * libaries/common.lib.php3: Fixed bug #636345 (Error when modifying table diff --git a/libraries/common.lib.php3 b/libraries/common.lib.php3 index fdb86640b..ec75cff7e 100644 --- a/libraries/common.lib.php3 +++ b/libraries/common.lib.php3 @@ -1278,7 +1278,7 @@ if (typeof(document.getElementById) != 'undefined' } else if (!empty($GLOBALS['validatequery'])) { // skip the extra bit here } else { - echo PMA_formatSql(PMA_SQP_parse($GLOBALS['sql_limit_to_append'])); + echo ' ' . PMA_formatSql(PMA_SQP_parse($GLOBALS['sql_limit_to_append'])); } } diff --git a/libraries/sqlparser.lib.php3 b/libraries/sqlparser.lib.php3 index 9d6830bf4..5ade90f38 100644 --- a/libraries/sqlparser.lib.php3 +++ b/libraries/sqlparser.lib.php3 @@ -622,15 +622,15 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { // must be sorted $supported_query_types = array( + 'SELECT' + /* + // Support for these additional query types will come later on. 'DELETE', 'INSERT', 'REPLACE', - 'SELECT', + 'SELECT' 'TRUNCATE', 'UPDATE' - /* - // Support for these additional query types will come later on. - // They are not needed yet 'EXPLAIN', 'DESCRIBE', 'SHOW', @@ -989,7 +989,11 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { $class .= 'syntax_' . $arr['type']; - return '' . htmlspecialchars($arr['data']) . '' . "\n"; + //TODO: check why adding a "\n" after the would cause extra + // blanks to be displayed: + // SELECT p . person_name + + return '' . htmlspecialchars($arr['data']) . ''; } // end of the "PMA_SQP_formatHtml_colorize()" function @@ -1188,7 +1192,12 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { && PMA_STR_binarySearchInArr(strtoupper($arr[$i - 1]['data']), $keywords_no_newline, $keywords_no_newline_cnt))) && ($typearr[1] != 'punct_level_plus') && (!PMA_STR_binarySearchInArr($upper, $keywords_no_newline, $keywords_no_newline_cnt))) { - $before .= $space_alpha_reserved_word; + // do not put a space before the first token, because + // we use a lot of eregi() checking for the first + // reserved word at beginning of query + if ($i > 0) { + $before .= $space_alpha_reserved_word; + } } else { $before .= ' '; } diff --git a/sql.php3 b/sql.php3 index 93a491abd..9b44284ef 100755 --- a/sql.php3 +++ b/sql.php3 @@ -81,8 +81,12 @@ if (isset($btnDrop) || isset($navig)) { /** * Reformat the query */ -$parsed_sql = PMA_SQP_parse((get_magic_quotes_gpc() ? stripslashes($sql_query) : $sql_query)); + +$sql_query = (get_magic_quotes_gpc() ? stripslashes($sql_query) : $sql_query); +$parsed_sql = PMA_SQP_parse($sql_query); +$is_select = eregi('^SELECT[[:space:]]+', $sql_query); $analyzed_sql = PMA_SQP_analyze($parsed_sql); + $sql_query = PMA_SQP_formatHtml($parsed_sql, 'query_only'); // If the query is a Select, extract the db and table names and modify @@ -96,7 +100,6 @@ $sql_query = PMA_SQP_formatHtml($parsed_sql, 'query_only'); // - do not show a table name in the page header // - do not display the sub-pages links) -$is_select = eregi('^SELECT[[:space:]]+', $sql_query); if ($is_select) { eregi('^SELECT[[:space:]]+(.*)[[:space:]]+FROM[[:space:]]+(`[^`]+`|[A-Za-z0-9_$]+)([\.]*)(`[^`]*`|[A-Za-z0-9_$]*)', $sql_query, $tmp); @@ -473,9 +476,6 @@ else { $dontlimitchars = 0; } - //$parsed_sql = PMA_SQP_parse($sql_query); - //$analyzed_sql = PMA_SQP_analyze($parsed_sql); - PMA_displayTable($result, $disp_mode, $analyzed_sql); mysql_free_result($result);