From 593b3536709a5a55068b6b2a3092c9567337aed0 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sat, 20 Jan 2007 15:04:18 +0000 Subject: [PATCH] bug #1638267, wrong reserved word recognition --- ChangeLog | 4 ++++ libraries/sqlparser.lib.php | 22 +++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5aa5b229a..3fe7e6277 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ phpMyAdmin - ChangeLog $Id$ $HeadURL$ +2007-01-20 Marc Delisle + * libraries/sqlparser.lib.php: bug #1638267, wrong reserved word + recognition + 2007-01-19 Marc Delisle * pmd*, lang/*: Designer now supports set/unset of the display field, thanks to Ivan Kirillov diff --git a/libraries/sqlparser.lib.php b/libraries/sqlparser.lib.php index f392e1a04..f4f0337bc 100644 --- a/libraries/sqlparser.lib.php +++ b/libraries/sqlparser.lib.php @@ -680,6 +680,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { // operation. $sql_array['len'] = $arraysize; + // DEBUG echo 'After parsing
'; print_r($sql_array); echo '
'; // Sends the data back return $sql_array; } // end of the "PMA_SQP_parse()" function @@ -917,7 +918,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { // loop #1 for each token: select_expr, table_ref for SELECT for ($i = 0; $i < $size; $i++) { -//DEBUG echo "trace loop1 " . $arr[$i]['data'] . " (" . $arr[$i]['type'] . ")
"; +//DEBUG echo "Loop1 " . $arr[$i]['data'] . " (" . $arr[$i]['type'] . ")
"; // High speed seek for locating the end of the current query if ($seek_queryend == TRUE) { @@ -1341,7 +1342,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { $current_identifier = ''; for ($i = 0; $i < $size; $i++) { -//DEBUG echo "trace loop2 " . $arr[$i]['data'] . " (" . $arr[$i]['type'] . ")
"; +//DEBUG echo "Loop2 " . $arr[$i]['data'] . " (" . $arr[$i]['type'] . ")
"; // need_confirm // @@ -1496,7 +1497,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { } // endif (reservedWord) - // do not add a blank after a function name + // do not add a space after a function name /** * @todo can we combine loop 2 and loop 1? some code is repeated here... */ @@ -1525,6 +1526,16 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { } } + // do not add a space after an identifier if followed by a dot + if ($arr[$i]['type'] == 'alpha_identifier' && $i < $size - 1 && $arr[$i + 1]['data'] == '.') { + $sep = ''; + } + + // do not add a space after a dot if followed by an identifier + if ($arr[$i]['data'] == '.' && $i < $size - 1 && $arr[$i + 1]['type'] == 'alpha_identifier') { + $sep = ''; + } + if ($in_select_expr && $upper_data != 'SELECT' && $upper_data != 'DISTINCT') { $select_expr_clause .= $arr[$i]['data'] . $sep; } @@ -1604,7 +1615,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { $seen_default = FALSE; for ($i = 0; $i < $size; $i++) { - // DEBUG echo "" . $arr[$i]['data'] . " " . $arr[$i]['type'] . "
"; + // DEBUG echo "Loop 3 " . $arr[$i]['data'] . " " . $arr[$i]['type'] . "
"; if ($arr[$i]['type'] == 'alpha_reservedWord') { $upper_data = strtoupper($arr[$i]['data']); @@ -1900,6 +1911,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { function PMA_SQP_formatHtml($arr, $mode='color', $start_token=0, $number_of_tokens=-1) { + //DEBUG echo 'in Format
'; print_r($arr); echo '
'; // then check for an array if (!is_array($arr)) { return htmlspecialchars($arr); @@ -1995,7 +2007,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) { $in_priv_list = FALSE; for ($i = $start_token; $i < $arraysize; $i++) { -// DEBUG echo "" . $arr[$i]['data'] . " " . $arr[$i]['type'] . "
"; +// DEBUG echo "Loop format " . $arr[$i]['data'] . " " . $arr[$i]['type'] . "
"; $before = ''; $after = ''; $indent = 0;