From eb577f4a0dbb41c6a35c2091555e954d1295b6ad Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Fri, 22 Nov 2002 19:49:00 +0000 Subject: [PATCH] bug 642319 --- ChangeLog | 2 ++ libraries/display_tbl.lib.php3 | 1 + libraries/sqlparser.lib.php3 | 10 +++++----- sql.php3 | 7 +++++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index a719dfc1c..8be9b39de 100755 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ $Source$ 2002-11-22 Marc Delisle * libraries/display_tbl.lib.php3: numeric foreign keys used as alias + * sql.php3, libraries/sqlparser.lib.php3: bug 642319, navigation + and GROUP BY 2002-11-22 Alexander M. Turek * scripts/create-release.sh: The script should now work at the SF shell diff --git a/libraries/display_tbl.lib.php3 b/libraries/display_tbl.lib.php3 index 28472a424..6f07560e2 100644 --- a/libraries/display_tbl.lib.php3 +++ b/libraries/display_tbl.lib.php3 @@ -166,6 +166,7 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) { // displayed but there is only one row, change these settings to // false if ($do_display['nav_bar'] == '1' || $do_display['sort_lnk'] == '1') { + if (isset($unlim_num_rows) && $unlim_num_rows < 2) { $do_display['nav_bar'] = (string) '0'; $do_display['sort_lnk'] = (string) '0'; diff --git a/libraries/sqlparser.lib.php3 b/libraries/sqlparser.lib.php3 index ba28f0d76..811720f0b 100644 --- a/libraries/sqlparser.lib.php3 +++ b/libraries/sqlparser.lib.php3 @@ -2,7 +2,6 @@ /* $Id$ */ // vim: expandtab sw=4 ts=4 sts=4: -error_reporting(E_ALL); /** SQL Parser Functions for phpMyAdmin * * Copyright 2002 Robin Johnson @@ -1186,12 +1185,13 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { } break; case 'alpha_reservedWord': - $upper = $arr[$i]['data']; + //$upper = $arr[$i]['data']; + $arr[$i]['data'] = strtoupper($arr[$i]['data']); if ((($typearr[1] != 'alpha_reservedWord') || (($typearr[1] == 'alpha_reservedWord') && 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))) { + && (!PMA_STR_binarySearchInArr($arr[$i]['data'], $keywords_no_newline, $keywords_no_newline_cnt))) { // 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 @@ -1202,7 +1202,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { $before .= ' '; } - switch ($upper) { + switch ($arr[$i]['data']) { case 'CREATE': $space_punct_listsep = $html_line_break; $space_alpha_reserved_word = ' '; @@ -1236,7 +1236,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { break; default: break; - } // end switch ($upper) + } // end switch ($arr[$i]['data']) $after .= ' '; break; diff --git a/sql.php3 b/sql.php3 index 72d032e59..704dd7129 100755 --- a/sql.php3 +++ b/sql.php3 @@ -82,10 +82,12 @@ if (isset($btnDrop) || isset($navig)) { */ $parsed_sql = PMA_SQP_parse((get_magic_quotes_gpc() ? stripslashes($sql_query) : $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'); +// here we are sure that SELECT is uppercase +$is_select = eregi('^SELECT[[:space:]]+', $sql_query); + // If the query is a Select, extract the db and table names and modify // $db and $table, to have correct page headers, links and left frame. // db and table name may be enclosed with backquotes, db is optionnal, @@ -232,7 +234,8 @@ else { // "SELECT COUNT(...) FROM ... GROUP BY ..." $is_explain = $is_count = $is_export = $is_delete = $is_insert = $is_affected = $is_show = $is_maint = $is_analyse = $is_group = $is_func = FALSE; if ($is_select) { // see line 141 - $is_group = eregi('[[:space:]]+(GROUP BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+', $sql_query); + $is_group = eregi('[[:space:]]+(GROUP[[:space:]]+BY|HAVING|SELECT[[:space:]]+DISTINCT)[[:space:]]+', $sql_query); + $is_func = !$is_group && (eregi('[[:space:]]+(SUM|AVG|STD|STDDEV|MIN|MAX|BIT_OR|BIT_AND)\s*\(', $sql_query)); $is_count = !$is_group && (eregi('^SELECT[[:space:]]+COUNT\((.*\.+)?.*\)', $sql_query)); $is_export = (eregi('[[:space:]]+INTO[[:space:]]+OUTFILE[[:space:]]+', $sql_query));