The branch, master has been updated via 4a2cedf720259b4f4f26de86c2d6adc9723e6815 (commit) from 197abc88a82e43f3ad2674d93fdbcf7f017874dc (commit)
- Log ----------------------------------------------------------------- commit 4a2cedf720259b4f4f26de86c2d6adc9723e6815 Author: Michal Čihař mcihar@suse.cz Date: Mon Aug 8 16:26:50 2011 +0200
Adjust switch blocks to PEAR coding standards
-----------------------------------------------------------------------
Summary of changes: libraries/sqlparser.lib.php | 902 +++++++++++++++++++++--------------------- 1 files changed, 451 insertions(+), 451 deletions(-)
diff --git a/libraries/sqlparser.lib.php b/libraries/sqlparser.lib.php index b7b0455..fba2719 100644 --- a/libraries/sqlparser.lib.php +++ b/libraries/sqlparser.lib.php @@ -310,19 +310,19 @@ if (! defined('PMA_MINIMUM_COMMON')) { $pos = 0; $type = 'bad'; switch ($c) { - case '#': - $type = 'mysql'; - case '-': - $type = 'ansi'; - $pos = $GLOBALS['PMA_strpos']($sql, "\n", $count2); - break; - case '/': - $type = 'c'; - $pos = $GLOBALS['PMA_strpos']($sql, '*/', $count2); - $pos += 2; - break; - default: - break; + case '#': + $type = 'mysql'; + case '-': + $type = 'ansi'; + $pos = $GLOBALS['PMA_strpos']($sql, "\n", $count2); + break; + case '/': + $type = 'c'; + $pos = $GLOBALS['PMA_strpos']($sql, '*/', $count2); + $pos += 2; + break; + default: + break; } // end switch $count2 = ($pos < $count2) ? $len : $pos; $str = $GLOBALS['PMA_substr']($sql, $count1, $count2 - $count1); @@ -401,20 +401,20 @@ if (! defined('PMA_MINIMUM_COMMON')) { $count2++; $type = 'quote_'; switch ($quotetype) { - case ''': - $type .= 'single'; - $this_was_quote = true; - break; - case '"': - $type .= 'double'; - $this_was_quote = true; - break; - case '`': - $type .= 'backtick'; - $this_was_quote = true; - break; - default: - break; + case ''': + $type .= 'single'; + $this_was_quote = true; + break; + case '"': + $type .= 'double'; + $this_was_quote = true; + break; + case '`': + $type .= 'backtick'; + $this_was_quote = true; + break; + default: + break; } // end switch $data = $GLOBALS['PMA_substr']($sql, $count1, $count2 - $count1); PMA_SQP_arrayAdd($sql_array, $type, $data, $arraysize); @@ -600,19 +600,19 @@ if (! defined('PMA_MINIMUM_COMMON')) { if ($l == 1) { $t_suffix = ''; switch ($punct_data) { - case $punct_queryend: - $t_suffix = '_queryend'; - break; - case $punct_qualifier: - $t_suffix = '_qualifier'; - $this_was_punct = true; - break; - case $punct_listsep: - $this_was_listsep = true; - $t_suffix = '_listsep'; - break; - default: - break; + case $punct_queryend: + $t_suffix = '_queryend'; + break; + case $punct_qualifier: + $t_suffix = '_qualifier'; + $this_was_punct = true; + break; + case $punct_listsep: + $this_was_listsep = true; + $t_suffix = '_listsep'; + break; + default: + break; } PMA_SQP_arrayAdd($sql_array, 'punct' . $t_suffix, $punct_data, $arraysize); } elseif ($punct_data == $GLOBALS['sql_delimiter'] || isset($allpunct_list_pair[$punct_data])) { @@ -1165,23 +1165,23 @@ if (! defined('PMA_MINIMUM_COMMON')) { && $arr[$i]['forbidden'] == false)) {
switch ($arr[$i]['type']) { - case 'alpha_identifier': - case 'alpha_reservedWord': - /** - * this is not a real reservedWord, because it's not - * present in the list of forbidden words, for example - * "storage" which can be used as an identifier - * - * @todo avoid the pretty printing in color in this case - */ - $identifier = $arr[$i]['data']; - break; + case 'alpha_identifier': + case 'alpha_reservedWord': + /** + * this is not a real reservedWord, because it's not + * present in the list of forbidden words, for example + * "storage" which can be used as an identifier + * + * @todo avoid the pretty printing in color in this case + */ + $identifier = $arr[$i]['data']; + break;
- case 'quote_backtick': - case 'quote_double': - case 'quote_single': - $identifier = PMA_unQuote($arr[$i]['data']); - break; + case 'quote_backtick': + case 'quote_double': + case 'quote_single': + $identifier = PMA_unQuote($arr[$i]['data']); + break; } // end switch
if ($subresult['querytype'] == 'SELECT' @@ -2101,21 +2101,21 @@ if (! defined('PMA_MINIMUM_COMMON')) { } // else do it properly switch ($mode) { - case 'color': - $str = '<span class="syntax">'; - $html_line_break = '<br />'; - $docu = true; - break; - case 'query_only': - $str = ''; - $html_line_break = "\n"; - $docu = false; - break; - case 'text': - $str = ''; - $html_line_break = '<br />'; - $docu = true; - break; + case 'color': + $str = '<span class="syntax">'; + $html_line_break = '<br />'; + $docu = true; + break; + case 'query_only': + $str = ''; + $html_line_break = "\n"; + $docu = false; + break; + case 'text': + $str = ''; + $html_line_break = '<br />'; + $docu = true; + break; } // end switch // inner_sql is a span that exists for all cases, except query_only // of $cfg['SQP']['fmtType'] to make possible a replacement @@ -2209,424 +2209,424 @@ if (! defined('PMA_MINIMUM_COMMON')) { }
switch ($typearr[2]) { - case 'alpha_bitfield_constant_introducer': - $before = ' '; + case 'alpha_bitfield_constant_introducer': + $before = ' '; + $after = ''; + break; + case 'white_newline': + $before = ''; + break; + case 'punct_bracket_open_round': + $bracketlevel++; + $infunction = false; + // Make sure this array is sorted! + if (($typearr[1] == 'alpha_functionName') || ($typearr[1] == 'alpha_columnType') || ($typearr[1] == 'punct') + || ($typearr[3] == 'digit_integer') || ($typearr[3] == 'digit_hex') || ($typearr[3] == 'digit_float') + || (($typearr[0] == 'alpha_reservedWord') + && isset($keywords_with_brackets_2before[strtoupper($arr[$i - 2]['data'])])) + || (($typearr[1] == 'alpha_reservedWord') + && isset($keywords_with_brackets_1before[strtoupper($arr[$i - 1]['data'])])) + ) { + $functionlevel++; + $infunction = true; + $after .= ' '; + } else { + $indent++; + $after .= ($mode != 'query_only' ? '<div class="syntax_indent' . $indent . '">' : ' '); + } + break; + case 'alpha_identifier': + if (($typearr[1] == 'punct_qualifier') || ($typearr[3] == 'punct_qualifier')) { $after = ''; - break; - case 'white_newline': $before = ''; - break; - case 'punct_bracket_open_round': - $bracketlevel++; - $infunction = false; - // Make sure this array is sorted! - if (($typearr[1] == 'alpha_functionName') || ($typearr[1] == 'alpha_columnType') || ($typearr[1] == 'punct') - || ($typearr[3] == 'digit_integer') || ($typearr[3] == 'digit_hex') || ($typearr[3] == 'digit_float') - || (($typearr[0] == 'alpha_reservedWord') - && isset($keywords_with_brackets_2before[strtoupper($arr[$i - 2]['data'])])) - || (($typearr[1] == 'alpha_reservedWord') - && isset($keywords_with_brackets_1before[strtoupper($arr[$i - 1]['data'])])) - ) { - $functionlevel++; - $infunction = true; - $after .= ' '; - } else { - $indent++; - $after .= ($mode != 'query_only' ? '<div class="syntax_indent' . $indent . '">' : ' '); - } - break; - case 'alpha_identifier': - if (($typearr[1] == 'punct_qualifier') || ($typearr[3] == 'punct_qualifier')) { - $after = ''; - $before = ''; - } - // for example SELECT 1 somealias - if ($typearr[1] == 'digit_integer') { - $before = ' '; - } - if (($typearr[3] == 'alpha_columnType') || ($typearr[3] == 'alpha_identifier')) { - $after .= ' '; - } - break; - case 'punct_user': - case 'punct_qualifier': - $before = ''; - $after = ''; - break; - case 'punct_listsep': - if ($infunction == true) { - $after .= $space_punct_listsep_function_name; - } else { - $after .= $space_punct_listsep; - } - break; - case 'punct_queryend': - if (($typearr[3] != 'comment_mysql') && ($typearr[3] != 'comment_ansi') && $typearr[3] != 'comment_c') { - $after .= $html_line_break; - $after .= $html_line_break; - } - $space_punct_listsep = ' '; - $space_punct_listsep_function_name = ' '; - $space_alpha_reserved_word = ' '; - $in_priv_list = false; - break; - case 'comment_mysql': - case 'comment_ansi': - $after .= $html_line_break; - break; - case 'punct': - $before .= ' '; - if ($docu && isset($PMA_SQPdata_operators_docs[$arr[$i]['data']]) && - ($arr[$i]['data'] != '*' || in_array($arr[$i]['type'], array('digit_integer','digit_float','digit_hex')))) { - $before .= PMA_showMySQLDocu( - 'functions', - $PMA_SQPdata_operators_docs[$arr[$i]['data']]['link'], - false, - $PMA_SQPdata_operators_docs[$arr[$i]['data']]['anchor'], - true); - $after .= '</a>'; - } + } + // for example SELECT 1 somealias + if ($typearr[1] == 'digit_integer') { + $before = ' '; + } + if (($typearr[3] == 'alpha_columnType') || ($typearr[3] == 'alpha_identifier')) { + $after .= ' '; + } + break; + case 'punct_user': + case 'punct_qualifier': + $before = ''; + $after = ''; + break; + case 'punct_listsep': + if ($infunction == true) { + $after .= $space_punct_listsep_function_name; + } else { + $after .= $space_punct_listsep; + } + break; + case 'punct_queryend': + if (($typearr[3] != 'comment_mysql') && ($typearr[3] != 'comment_ansi') && $typearr[3] != 'comment_c') { + $after .= $html_line_break; + $after .= $html_line_break; + } + $space_punct_listsep = ' '; + $space_punct_listsep_function_name = ' '; + $space_alpha_reserved_word = ' '; + $in_priv_list = false; + break; + case 'comment_mysql': + case 'comment_ansi': + $after .= $html_line_break; + break; + case 'punct': + $before .= ' '; + if ($docu && isset($PMA_SQPdata_operators_docs[$arr[$i]['data']]) && + ($arr[$i]['data'] != '*' || in_array($arr[$i]['type'], array('digit_integer','digit_float','digit_hex')))) { + $before .= PMA_showMySQLDocu( + 'functions', + $PMA_SQPdata_operators_docs[$arr[$i]['data']]['link'], + false, + $PMA_SQPdata_operators_docs[$arr[$i]['data']]['anchor'], + true); + $after .= '</a>'; + }
- // workaround for - // select * from mytable limit 0,-1 - // (a side effect of this workaround is that - // select 20 - 9 - // becomes - // select 20 -9 - // ) - if ($typearr[3] != 'digit_integer') { - $after .= ' '; - } - break; - case 'punct_bracket_close_round': - // only close bracket level when it was opened before - if ($bracketlevel > 0) { - $bracketlevel--; - if ($infunction == true) { - $functionlevel--; - $after .= ' '; - $before .= ' '; - } else { - $indent--; - $before .= ($mode != 'query_only' ? '</div>' : ' '); - } - $infunction = ($functionlevel > 0) ? true : false; - } - break; - case 'alpha_columnType': - if ($docu) { - switch ($arr[$i]['data']) { - case 'tinyint': - case 'smallint': - case 'mediumint': - case 'int': - case 'bigint': - case 'decimal': - case 'float': - case 'double': - case 'real': - case 'bit': - case 'boolean': - case 'serial': - $before .= PMA_showMySQLDocu('data-types', 'numeric-types', false, '', true); - $after = '</a>' . $after; - break; - case 'date': - case 'datetime': - case 'timestamp': - case 'time': - case 'year': - $before .= PMA_showMySQLDocu('data-types', 'date-and-time-types', false, '', true); - $after = '</a>' . $after; - break; - case 'char': - case 'varchar': - case 'tinytext': - case 'text': - case 'mediumtext': - case 'longtext': - case 'binary': - case 'varbinary': - case 'tinyblob': - case 'mediumblob': - case 'blob': - case 'longblob': - case 'enum': - case 'set': - $before .= PMA_showMySQLDocu('data-types', 'string-types', false, '', true); - $after = '</a>' . $after; - break; - } - } - if ($typearr[3] == 'alpha_columnAttrib') { + // workaround for + // select * from mytable limit 0,-1 + // (a side effect of this workaround is that + // select 20 - 9 + // becomes + // select 20 -9 + // ) + if ($typearr[3] != 'digit_integer') { + $after .= ' '; + } + break; + case 'punct_bracket_close_round': + // only close bracket level when it was opened before + if ($bracketlevel > 0) { + $bracketlevel--; + if ($infunction == true) { + $functionlevel--; $after .= ' '; - } - if ($typearr[1] == 'alpha_columnType') { $before .= ' '; + } else { + $indent--; + $before .= ($mode != 'query_only' ? '</div>' : ' '); } - break; - case 'alpha_columnAttrib': - - // ALTER TABLE tbl_name AUTO_INCREMENT = 1 - // COLLATE LATIN1_GENERAL_CI DEFAULT - if ($typearr[1] == 'alpha_identifier' || $typearr[1] == 'alpha_charset') { - $before .= ' '; - } - if (($typearr[3] == 'alpha_columnAttrib') || ($typearr[3] == 'quote_single') || ($typearr[3] == 'digit_integer')) { - $after .= ' '; + $infunction = ($functionlevel > 0) ? true : false; + } + break; + case 'alpha_columnType': + if ($docu) { + switch ($arr[$i]['data']) { + case 'tinyint': + case 'smallint': + case 'mediumint': + case 'int': + case 'bigint': + case 'decimal': + case 'float': + case 'double': + case 'real': + case 'bit': + case 'boolean': + case 'serial': + $before .= PMA_showMySQLDocu('data-types', 'numeric-types', false, '', true); + $after = '</a>' . $after; + break; + case 'date': + case 'datetime': + case 'timestamp': + case 'time': + case 'year': + $before .= PMA_showMySQLDocu('data-types', 'date-and-time-types', false, '', true); + $after = '</a>' . $after; + break; + case 'char': + case 'varchar': + case 'tinytext': + case 'text': + case 'mediumtext': + case 'longtext': + case 'binary': + case 'varbinary': + case 'tinyblob': + case 'mediumblob': + case 'blob': + case 'longblob': + case 'enum': + case 'set': + $before .= PMA_showMySQLDocu('data-types', 'string-types', false, '', true); + $after = '</a>' . $after; + break; } - // workaround for - // AUTO_INCREMENT = 31DEFAULT_CHARSET = utf-8 + } + if ($typearr[3] == 'alpha_columnAttrib') { + $after .= ' '; + } + if ($typearr[1] == 'alpha_columnType') { + $before .= ' '; + } + break; + case 'alpha_columnAttrib':
- if ($typearr[2] == 'alpha_columnAttrib' && $typearr[3] == 'alpha_reservedWord') { - $before .= ' '; - } - // workaround for - // select * from mysql.user where binary user="root" - // binary is marked as alpha_columnAttrib - // but should be marked as a reserved word - if (strtoupper($arr[$i]['data']) == 'BINARY' - && $typearr[3] == 'alpha_identifier') { - $after .= ' '; - } - break; - case 'alpha_functionName': - $funcname = strtoupper($arr[$i]['data']); - if ($docu && isset($PMA_SQPdata_functions_docs[$funcname])) { - $before .= PMA_showMySQLDocu( - 'functions', - $PMA_SQPdata_functions_docs[$funcname]['link'], - false, - $PMA_SQPdata_functions_docs[$funcname]['anchor'], - true); - $after .= '</a>'; - } - break; - case 'alpha_reservedWord': - // do not uppercase the reserved word if we are calling - // this function in query_only mode, because we need - // the original query (otherwise we get problems with - // semi-reserved words like "storage" which is legal - // as an identifier name) - - if ($mode != 'query_only') { - $arr[$i]['data'] = strtoupper($arr[$i]['data']); - } + // ALTER TABLE tbl_name AUTO_INCREMENT = 1 + // COLLATE LATIN1_GENERAL_CI DEFAULT + if ($typearr[1] == 'alpha_identifier' || $typearr[1] == 'alpha_charset') { + $before .= ' '; + } + if (($typearr[3] == 'alpha_columnAttrib') || ($typearr[3] == 'quote_single') || ($typearr[3] == 'digit_integer')) { + $after .= ' '; + } + // workaround for + // AUTO_INCREMENT = 31DEFAULT_CHARSET = utf-8
- if ((($typearr[1] != 'alpha_reservedWord') - || (($typearr[1] == 'alpha_reservedWord') - && isset($keywords_no_newline[strtoupper($arr[$i - 1]['data'])]))) - && ($typearr[1] != 'punct_level_plus') - && (!isset($keywords_no_newline[$arr[$i]['data']]))) { - // do not put a space before the first token, because - // we use a lot of pattern matching checking for the - // first reserved word at beginning of query - // so do not put a newline before + if ($typearr[2] == 'alpha_columnAttrib' && $typearr[3] == 'alpha_reservedWord') { + $before .= ' '; + } + // workaround for + // select * from mysql.user where binary user="root" + // binary is marked as alpha_columnAttrib + // but should be marked as a reserved word + if (strtoupper($arr[$i]['data']) == 'BINARY' + && $typearr[3] == 'alpha_identifier') { + $after .= ' '; + } + break; + case 'alpha_functionName': + $funcname = strtoupper($arr[$i]['data']); + if ($docu && isset($PMA_SQPdata_functions_docs[$funcname])) { + $before .= PMA_showMySQLDocu( + 'functions', + $PMA_SQPdata_functions_docs[$funcname]['link'], + false, + $PMA_SQPdata_functions_docs[$funcname]['anchor'], + true); + $after .= '</a>'; + } + break; + case 'alpha_reservedWord': + // do not uppercase the reserved word if we are calling + // this function in query_only mode, because we need + // the original query (otherwise we get problems with + // semi-reserved words like "storage" which is legal + // as an identifier name) + + if ($mode != 'query_only') { + $arr[$i]['data'] = strtoupper($arr[$i]['data']); + } + + if ((($typearr[1] != 'alpha_reservedWord') + || (($typearr[1] == 'alpha_reservedWord') + && isset($keywords_no_newline[strtoupper($arr[$i - 1]['data'])]))) + && ($typearr[1] != 'punct_level_plus') + && (!isset($keywords_no_newline[$arr[$i]['data']]))) { + // do not put a space before the first token, because + // we use a lot of pattern matching checking for the + // first reserved word at beginning of query + // so do not put a newline before + // + // also we must not be inside a privilege list + if ($i > 0) { + // the alpha_identifier exception is there to + // catch cases like + // GRANT SELECT ON mydb.mytable TO myuser@localhost + // (else, we get mydb.mytableTO) // - // also we must not be inside a privilege list - if ($i > 0) { - // the alpha_identifier exception is there to - // catch cases like - // GRANT SELECT ON mydb.mytable TO myuser@localhost - // (else, we get mydb.mytableTO) - // - // the quote_single exception is there to - // catch cases like - // GRANT ... TO 'marc'@'domain.com' IDENTIFIED... - /** - * @todo fix all cases and find why this happens - */ + // the quote_single exception is there to + // catch cases like + // GRANT ... TO 'marc'@'domain.com' IDENTIFIED... + /** + * @todo fix all cases and find why this happens + */
- if (!$in_priv_list || $typearr[1] == 'alpha_identifier' || $typearr[1] == 'quote_single' || $typearr[1] == 'white_newline') { - $before .= $space_alpha_reserved_word; - } - } else { - // on first keyword, check if it introduces a - // privilege list - if (isset($keywords_priv_list[$arr[$i]['data']])) { - $in_priv_list = true; - } + if (!$in_priv_list || $typearr[1] == 'alpha_identifier' || $typearr[1] == 'quote_single' || $typearr[1] == 'white_newline') { + $before .= $space_alpha_reserved_word; } } else { - $before .= ' '; + // on first keyword, check if it introduces a + // privilege list + if (isset($keywords_priv_list[$arr[$i]['data']])) { + $in_priv_list = true; + } } + } else { + $before .= ' '; + }
- switch ($arr[$i]['data']) { - case 'CREATE': - case 'ALTER': - case 'DROP': - case 'RENAME'; - case 'TRUNCATE': - case 'ANALYZE': - case 'ANALYSE': - case 'OPTIMIZE': - if ($docu) { - switch ($arr[$i + 1]['data']) { - case 'EVENT': - case 'TABLE': - case 'TABLESPACE': - case 'FUNCTION': - case 'INDEX': - case 'PROCEDURE': - case 'TRIGGER': - case 'SERVER': - case 'DATABASE': - case 'VIEW': - $before .= PMA_showMySQLDocu('SQL-Syntax', $arr[$i]['data'] . '_' . $arr[$i + 1]['data'], false, '', true); - $close_docu_link = true; - break; - } - if ($arr[$i + 1]['data'] == 'LOGFILE' && $arr[$i + 2]['data'] == 'GROUP') { - $before .= PMA_showMySQLDocu('SQL-Syntax', $arr[$i]['data'] . '_LOGFILE_GROUP', false, '', true); - $close_docu_link = true; - } - } - if (!$in_priv_list) { - $space_punct_listsep = $html_line_break; - $space_alpha_reserved_word = ' '; - } - break; + switch ($arr[$i]['data']) { + case 'CREATE': + case 'ALTER': + case 'DROP': + case 'RENAME'; + case 'TRUNCATE': + case 'ANALYZE': + case 'ANALYSE': + case 'OPTIMIZE': + if ($docu) { + switch ($arr[$i + 1]['data']) { case 'EVENT': - case 'TABLESPACE': case 'TABLE': + case 'TABLESPACE': case 'FUNCTION': case 'INDEX': case 'PROCEDURE': - case 'SERVER': case 'TRIGGER': + case 'SERVER': case 'DATABASE': case 'VIEW': - case 'GROUP': - if ($close_docu_link) { - $after = '</a>' . $after; - $close_docu_link = false; - } - break; - case 'SET': - if ($docu && ($i == 0 || $arr[$i - 1]['data'] != 'CHARACTER')) { - $before .= PMA_showMySQLDocu('SQL-Syntax', $arr[$i]['data'], false, '', true); - $after = '</a>' . $after; - } - if (!$in_priv_list) { - $space_punct_listsep = $html_line_break; - $space_alpha_reserved_word = ' '; - } - break; - case 'EXPLAIN': - case 'DESCRIBE': - case 'DELETE': - case 'SHOW': - case 'UPDATE': - if ($docu) { - $before .= PMA_showMySQLDocu('SQL-Syntax', $arr[$i]['data'], false, '', true); - $after = '</a>' . $after; - } - if (!$in_priv_list) { - $space_punct_listsep = $html_line_break; - $space_alpha_reserved_word = ' '; - } - break; - case 'INSERT': - case 'REPLACE': - if ($docu) { - $before .= PMA_showMySQLDocu('SQL-Syntax', $arr[$i]['data'], false, '', true); - $after = '</a>' . $after; - } - if (!$in_priv_list) { - $space_punct_listsep = $html_line_break; - $space_alpha_reserved_word = $html_line_break; - } - break; - case 'VALUES': - $space_punct_listsep = ' '; - $space_alpha_reserved_word = $html_line_break; - break; - case 'SELECT': - if ($docu) { - $before .= PMA_showMySQLDocu('SQL-Syntax', 'SELECT', false, '', true); - $after = '</a>' . $after; - } - $space_punct_listsep = ' '; - $space_alpha_reserved_word = $html_line_break; - break; - case 'CALL': - case 'DO': - case 'HANDLER': - if ($docu) { - $before .= PMA_showMySQLDocu('SQL-Syntax', $arr[$i]['data'], false, '', true); - $after = '</a>' . $after; - } + $before .= PMA_showMySQLDocu('SQL-Syntax', $arr[$i]['data'] . '_' . $arr[$i + 1]['data'], false, '', true); + $close_docu_link = true; break; - default: - if ($close_docu_link && in_array($arr[$i]['data'], array('LIKE', 'NOT', 'IN', 'REGEXP', 'NULL'))) { - $after .= '</a>'; - $close_docu_link = false; - } else if ($docu && isset($PMA_SQPdata_functions_docs[$arr[$i]['data']])) { - /* Handle multi word statements first */ - if (isset($typearr[4]) && $typearr[4] == 'alpha_reservedWord' && $typearr[3] == 'alpha_reservedWord' && isset($PMA_SQPdata_functions_docs[strtoupper($arr[$i]['data'] . '_' . $arr[$i + 1]['data'] . '_' . $arr[$i + 2]['data'])])) { - $tempname = strtoupper($arr[$i]['data'] . '_' . $arr[$i + 1]['data'] . '_' . $arr[$i + 2]['data']); - $before .= PMA_showMySQLDocu('functions', $PMA_SQPdata_functions_docs[$tempname]['link'], false, $PMA_SQPdata_functions_docs[$tempname]['anchor'], true); - $close_docu_link = true; - } else if (isset($typearr[3]) && $typearr[3] == 'alpha_reservedWord' && isset($PMA_SQPdata_functions_docs[strtoupper($arr[$i]['data'] . '_' . $arr[$i + 1]['data'])])) { - $tempname = strtoupper($arr[$i]['data'] . '_' . $arr[$i + 1]['data']); - $before .= PMA_showMySQLDocu('functions', $PMA_SQPdata_functions_docs[$tempname]['link'], false, $PMA_SQPdata_functions_docs[$tempname]['anchor'], true); - $close_docu_link = true; - } else { - $before .= PMA_showMySQLDocu('functions', $PMA_SQPdata_functions_docs[$arr[$i]['data']]['link'], false, $PMA_SQPdata_functions_docs[$arr[$i]['data']]['anchor'], true); - $after .= '</a>'; - } - } - break; - } // end switch ($arr[$i]['data']) - - $after .= ' '; + } + if ($arr[$i + 1]['data'] == 'LOGFILE' && $arr[$i + 2]['data'] == 'GROUP') { + $before .= PMA_showMySQLDocu('SQL-Syntax', $arr[$i]['data'] . '_LOGFILE_GROUP', false, '', true); + $close_docu_link = true; + } + } + if (!$in_priv_list) { + $space_punct_listsep = $html_line_break; + $space_alpha_reserved_word = ' '; + } break; - case 'digit_integer': - case 'digit_float': - case 'digit_hex': - /** - * @todo could there be other types preceding a digit? - */ - if ($typearr[1] == 'alpha_reservedWord') { - $after .= ' '; + case 'EVENT': + case 'TABLESPACE': + case 'TABLE': + case 'FUNCTION': + case 'INDEX': + case 'PROCEDURE': + case 'SERVER': + case 'TRIGGER': + case 'DATABASE': + case 'VIEW': + case 'GROUP': + if ($close_docu_link) { + $after = '</a>' . $after; + $close_docu_link = false; } - if ($infunction && $typearr[3] == 'punct_bracket_close_round') { - $after .= ' '; + break; + case 'SET': + if ($docu && ($i == 0 || $arr[$i - 1]['data'] != 'CHARACTER')) { + $before .= PMA_showMySQLDocu('SQL-Syntax', $arr[$i]['data'], false, '', true); + $after = '</a>' . $after; } - if ($typearr[1] == 'alpha_columnAttrib') { - $before .= ' '; + if (!$in_priv_list) { + $space_punct_listsep = $html_line_break; + $space_alpha_reserved_word = ' '; } break; - case 'alpha_variable': - $after = ' '; + case 'EXPLAIN': + case 'DESCRIBE': + case 'DELETE': + case 'SHOW': + case 'UPDATE': + if ($docu) { + $before .= PMA_showMySQLDocu('SQL-Syntax', $arr[$i]['data'], false, '', true); + $after = '</a>' . $after; + } + if (!$in_priv_list) { + $space_punct_listsep = $html_line_break; + $space_alpha_reserved_word = ' '; + } break; - case 'quote_double': - case 'quote_single': - // workaround: for the query - // REVOKE SELECT ON `base2_db`.* FROM 'user'@'%' - // the @ is incorrectly marked as alpha_variable - // in the parser, and here, the '%' gets a blank before, - // which is a syntax error - if ($typearr[1] != 'punct_user' && $typearr[1] != 'alpha_bitfield_constant_introducer') { - $before .= ' '; + case 'INSERT': + case 'REPLACE': + if ($docu) { + $before .= PMA_showMySQLDocu('SQL-Syntax', $arr[$i]['data'], false, '', true); + $after = '</a>' . $after; } - if ($infunction && $typearr[3] == 'punct_bracket_close_round') { - $after .= ' '; + if (!$in_priv_list) { + $space_punct_listsep = $html_line_break; + $space_alpha_reserved_word = $html_line_break; } break; - case 'quote_backtick': - // here we check for punct_user to handle correctly - // DEFINER = `username`@`%` - // where @ is the punct_user and `%` is the quote_backtick - if ($typearr[3] != 'punct_qualifier' && $typearr[3] != 'alpha_variable' && $typearr[3] != 'punct_user') { - $after .= ' '; + case 'VALUES': + $space_punct_listsep = ' '; + $space_alpha_reserved_word = $html_line_break; + break; + case 'SELECT': + if ($docu) { + $before .= PMA_showMySQLDocu('SQL-Syntax', 'SELECT', false, '', true); + $after = '</a>' . $after; } - if ($typearr[1] != 'punct_qualifier' && $typearr[1] != 'alpha_variable' && $typearr[1] != 'punct_user') { - $before .= ' '; + $space_punct_listsep = ' '; + $space_alpha_reserved_word = $html_line_break; + break; + case 'CALL': + case 'DO': + case 'HANDLER': + if ($docu) { + $before .= PMA_showMySQLDocu('SQL-Syntax', $arr[$i]['data'], false, '', true); + $after = '</a>' . $after; } break; default: + if ($close_docu_link && in_array($arr[$i]['data'], array('LIKE', 'NOT', 'IN', 'REGEXP', 'NULL'))) { + $after .= '</a>'; + $close_docu_link = false; + } else if ($docu && isset($PMA_SQPdata_functions_docs[$arr[$i]['data']])) { + /* Handle multi word statements first */ + if (isset($typearr[4]) && $typearr[4] == 'alpha_reservedWord' && $typearr[3] == 'alpha_reservedWord' && isset($PMA_SQPdata_functions_docs[strtoupper($arr[$i]['data'] . '_' . $arr[$i + 1]['data'] . '_' . $arr[$i + 2]['data'])])) { + $tempname = strtoupper($arr[$i]['data'] . '_' . $arr[$i + 1]['data'] . '_' . $arr[$i + 2]['data']); + $before .= PMA_showMySQLDocu('functions', $PMA_SQPdata_functions_docs[$tempname]['link'], false, $PMA_SQPdata_functions_docs[$tempname]['anchor'], true); + $close_docu_link = true; + } else if (isset($typearr[3]) && $typearr[3] == 'alpha_reservedWord' && isset($PMA_SQPdata_functions_docs[strtoupper($arr[$i]['data'] . '_' . $arr[$i + 1]['data'])])) { + $tempname = strtoupper($arr[$i]['data'] . '_' . $arr[$i + 1]['data']); + $before .= PMA_showMySQLDocu('functions', $PMA_SQPdata_functions_docs[$tempname]['link'], false, $PMA_SQPdata_functions_docs[$tempname]['anchor'], true); + $close_docu_link = true; + } else { + $before .= PMA_showMySQLDocu('functions', $PMA_SQPdata_functions_docs[$arr[$i]['data']]['link'], false, $PMA_SQPdata_functions_docs[$arr[$i]['data']]['anchor'], true); + $after .= '</a>'; + } + } break; + } // end switch ($arr[$i]['data']) + + $after .= ' '; + break; + case 'digit_integer': + case 'digit_float': + case 'digit_hex': + /** + * @todo could there be other types preceding a digit? + */ + if ($typearr[1] == 'alpha_reservedWord') { + $after .= ' '; + } + if ($infunction && $typearr[3] == 'punct_bracket_close_round') { + $after .= ' '; + } + if ($typearr[1] == 'alpha_columnAttrib') { + $before .= ' '; + } + break; + case 'alpha_variable': + $after = ' '; + break; + case 'quote_double': + case 'quote_single': + // workaround: for the query + // REVOKE SELECT ON `base2_db`.* FROM 'user'@'%' + // the @ is incorrectly marked as alpha_variable + // in the parser, and here, the '%' gets a blank before, + // which is a syntax error + if ($typearr[1] != 'punct_user' && $typearr[1] != 'alpha_bitfield_constant_introducer') { + $before .= ' '; + } + if ($infunction && $typearr[3] == 'punct_bracket_close_round') { + $after .= ' '; + } + break; + case 'quote_backtick': + // here we check for punct_user to handle correctly + // DEFINER = `username`@`%` + // where @ is the punct_user and `%` is the quote_backtick + if ($typearr[3] != 'punct_qualifier' && $typearr[3] != 'alpha_variable' && $typearr[3] != 'punct_user') { + $after .= ' '; + } + if ($typearr[1] != 'punct_qualifier' && $typearr[1] != 'alpha_variable' && $typearr[1] != 'punct_user') { + $before .= ' '; + } + break; + default: + break; } // end switch ($typearr[2])
/*
hooks/post-receive