* libraries/sqlparser.lib.php3:
- Spacing around if statements - Added require statements for parser - Moved to global constants for size of keyword arrays
This commit is contained in:
@@ -11,6 +11,9 @@ $Source$
|
|||||||
2002-07-24 Robin Johnson <robbat2@users.sourceforge.net>
|
2002-07-24 Robin Johnson <robbat2@users.sourceforge.net>
|
||||||
* libraries/string.lib.php3: optimizations (thanks Lo<4C>c)
|
* libraries/string.lib.php3: optimizations (thanks Lo<4C>c)
|
||||||
* libraries/sqlparser.lib.php3: SQL Parser merging (in progress)
|
* libraries/sqlparser.lib.php3: SQL Parser merging (in progress)
|
||||||
|
- Spacing around if statements
|
||||||
|
- Added require statements for parser
|
||||||
|
- Moved to global constants for size of keyword arrays
|
||||||
* libraries/sqlparser.data.php3: Merged
|
* libraries/sqlparser.data.php3: Merged
|
||||||
|
|
||||||
2002-07-24 Lo<4C>c Chapeaux <lolo@phpheaven.net>
|
2002-07-24 Lo<4C>c Chapeaux <lolo@phpheaven.net>
|
||||||
|
@@ -28,10 +28,14 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
||||||
define('PMA_SQP_LIB_INCLUDED', 1);
|
define('PMA_SQP_LIB_INCLUDED', 1);
|
||||||
|
|
||||||
if(!defined('DEBUGTIMING')) {
|
require('./libraries/string.lib.php3');
|
||||||
|
require('./libraries/sqlparser.data.php3');
|
||||||
|
|
||||||
|
if (!defined('DEBUGTIMING')) {
|
||||||
function PMA_SQP_ArrayAdd(&$arr,$type,$data, &$arrsize)
|
function PMA_SQP_ArrayAdd(&$arr,$type,$data, &$arrsize)
|
||||||
{
|
{
|
||||||
$arr[] = array( 'type' => $type, 'data' => $data );
|
$arr[] = array( 'type' => $type, 'data' => $data );
|
||||||
@@ -51,7 +55,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
function PMA_SQP_Parse($sql)
|
function PMA_SQP_Parse($sql)
|
||||||
{
|
{
|
||||||
$len = strlen($sql);
|
$len = strlen($sql);
|
||||||
if($len == 0) {
|
if ($len == 0) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
$sql_array = array();
|
$sql_array = array();
|
||||||
@@ -87,14 +91,14 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
$c = $sql[$count2];
|
$c = $sql[$count2];
|
||||||
$count1 = $count2;
|
$count1 = $count2;
|
||||||
|
|
||||||
if( ($c == "\n") ) {
|
if ( ($c == "\n") ) {
|
||||||
$count2++;
|
$count2++;
|
||||||
PMA_SQP_ArrayAdd( $sql_array, 'white_newline', '', $arraysize);
|
PMA_SQP_ArrayAdd( $sql_array, 'white_newline', '', $arraysize);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//check for white space
|
//check for white space
|
||||||
if(PMA_STR_IsSpace($c)) {
|
if (PMA_STR_IsSpace($c)) {
|
||||||
$count2++;
|
$count2++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -103,7 +107,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
// MySQL style #
|
// MySQL style #
|
||||||
// C style /* */
|
// C style /* */
|
||||||
// ANSI style --
|
// ANSI style --
|
||||||
if( ($c == '#') || (($count2+1 < $len) && ($c == '/') && ($sql[$count2+1] == '*')) || (($c == '-') && ($count2+2 < $len) && ($sql[$count2+1] == '-') && ($sql[$count2+2] == ' '))) {
|
if ( ($c == '#') || (($count2+1 < $len) && ($c == '/') && ($sql[$count2+1] == '*')) || (($c == '-') && ($count2+2 < $len) && ($sql[$count2+1] == '-') && ($sql[$count2+2] == ' '))) {
|
||||||
$count2++;
|
$count2++;
|
||||||
$pos = 0;
|
$pos = 0;
|
||||||
$type = 'bad';
|
$type = 'bad';
|
||||||
@@ -129,7 +133,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//check for something inside quotation marks
|
//check for something inside quotation marks
|
||||||
if(PMA_STR_StrInStr($c,$quote_list)) {
|
if (PMA_STR_StrInStr($c,$quote_list)) {
|
||||||
$startquotepos = $count2;
|
$startquotepos = $count2;
|
||||||
$quotetype = $c;
|
$quotetype = $c;
|
||||||
$count2++;
|
$count2++;
|
||||||
@@ -141,18 +145,18 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
$oldpos = $pos;
|
$oldpos = $pos;
|
||||||
$pos = strpos($sql,$quotetype,$oldpos);
|
$pos = strpos($sql,$quotetype,$oldpos);
|
||||||
// ($pos === FALSE)
|
// ($pos === FALSE)
|
||||||
if(!is_integer($pos)) {
|
if (!is_integer($pos)) {
|
||||||
trigger_error('Syntax: Unclosed quote ('.$quotetype.') at '.$startquotepos);
|
trigger_error('Syntax: Unclosed quote ('.$quotetype.') at '.$startquotepos);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if the quote is the first character,
|
//if the quote is the first character,
|
||||||
//it can't be escaped, so don't do the rest of the code
|
//it can't be escaped, so don't do the rest of the code
|
||||||
if($pos == 0) {
|
if ($pos == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(PMA_STR_CharIsEscaped($sql,$pos)) {
|
if (PMA_STR_CharIsEscaped($sql,$pos)) {
|
||||||
$pos ++;
|
$pos ++;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
@@ -181,19 +185,19 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//check for brackets
|
//check for brackets
|
||||||
if(PMA_STR_StrInStr($c,$bracket_list)) {
|
if (PMA_STR_StrInStr($c,$bracket_list)) {
|
||||||
//all bracket tokens are only one item long
|
//all bracket tokens are only one item long
|
||||||
$count2++;
|
$count2++;
|
||||||
$type_type = '';
|
$type_type = '';
|
||||||
if(PMA_STR_StrInStr($c,'([{')) {
|
if (PMA_STR_StrInStr($c,'([{')) {
|
||||||
$type_type = 'open';
|
$type_type = 'open';
|
||||||
} else {
|
} else {
|
||||||
$type_type = 'close';
|
$type_type = 'close';
|
||||||
}
|
}
|
||||||
$type_style = '';
|
$type_style = '';
|
||||||
if(PMA_STR_StrInStr($c,'()')) {
|
if (PMA_STR_StrInStr($c,'()')) {
|
||||||
$type_style = 'round';
|
$type_style = 'round';
|
||||||
} elseif(PMA_STR_StrInStr($c,'[]')) {
|
} elseif (PMA_STR_StrInStr($c,'[]')) {
|
||||||
$type_style = 'square';
|
$type_style = 'square';
|
||||||
} else {
|
} else {
|
||||||
$type_style = 'curly';
|
$type_style = 'curly';
|
||||||
@@ -204,13 +208,13 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//check for punct
|
//check for punct
|
||||||
if(PMA_STR_StrInStr($c,$allpunct_list))
|
if (PMA_STR_StrInStr($c,$allpunct_list))
|
||||||
{
|
{
|
||||||
while( ($count2 < $len) && PMA_STR_StrInStr($sql[$count2],$allpunct_list) ) {
|
while( ($count2 < $len) && PMA_STR_StrInStr($sql[$count2],$allpunct_list) ) {
|
||||||
$count2++;
|
$count2++;
|
||||||
}
|
}
|
||||||
$l = $count2-$count1;
|
$l = $count2-$count1;
|
||||||
if($l == 1) {
|
if ($l == 1) {
|
||||||
$punct_data = $c;
|
$punct_data = $c;
|
||||||
} else {
|
} else {
|
||||||
$punct_data = substr($sql,$count1,$l);
|
$punct_data = substr($sql,$count1,$l);
|
||||||
@@ -218,7 +222,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
|
|
||||||
//special case, sometimes, althought two characters are adjectent directly,
|
//special case, sometimes, althought two characters are adjectent directly,
|
||||||
//they ACTUALLY need to be seperate
|
//they ACTUALLY need to be seperate
|
||||||
if( $l == 1 ) {
|
if ( $l == 1 ) {
|
||||||
$t_suffix = '';
|
$t_suffix = '';
|
||||||
switch($punct_data) {
|
switch($punct_data) {
|
||||||
case $punct_queryend:
|
case $punct_queryend:
|
||||||
@@ -234,7 +238,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PMA_SQP_ArrayAdd ( $sql_array, 'punct'.$t_suffix, $punct_data, $arraysize);
|
PMA_SQP_ArrayAdd ( $sql_array, 'punct'.$t_suffix, $punct_data, $arraysize);
|
||||||
} elseif( PMA_STR_BinarySearchInArr($punct_data,$allpunct_list_pair,$allpunct_list_pair_size)) {
|
} elseif ( PMA_STR_BinarySearchInArr($punct_data,$allpunct_list_pair,$allpunct_list_pair_size)) {
|
||||||
//Ok, we have one of the valid combined punct expressions
|
//Ok, we have one of the valid combined punct expressions
|
||||||
PMA_SQP_ArrayAdd ( $sql_array, 'punct', $punct_data, $arraysize );
|
PMA_SQP_ArrayAdd ( $sql_array, 'punct', $punct_data, $arraysize );
|
||||||
} else {
|
} else {
|
||||||
@@ -243,13 +247,13 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
$first2 = $punct_data[0].$punct_data[1];
|
$first2 = $punct_data[0].$punct_data[1];
|
||||||
$last2 = $punct_data[$l-2].$punct_data[$l-1];
|
$last2 = $punct_data[$l-2].$punct_data[$l-1];
|
||||||
$last = $punct_data[$l-1];
|
$last = $punct_data[$l-1];
|
||||||
if(($first == ',') || ($first == ';') || ($first == '.') || $first = '*') {
|
if (($first == ',') || ($first == ';') || ($first == '.') || $first = '*') {
|
||||||
$count2 = $count1 + 1;
|
$count2 = $count1 + 1;
|
||||||
$punct_data = $first;
|
$punct_data = $first;
|
||||||
} elseif(($last2 == '/*') || ($last2 == '--')) {
|
} elseif (($last2 == '/*') || ($last2 == '--')) {
|
||||||
$count2-=2;
|
$count2-=2;
|
||||||
$punct_data = substr($sql,$count1,$count2-$count1);
|
$punct_data = substr($sql,$count1,$count2-$count1);
|
||||||
} elseif(($last == '-') || ($last == '+') || ($last == '!')) {
|
} elseif (($last == '-') || ($last == '+') || ($last == '!')) {
|
||||||
$count2--;
|
$count2--;
|
||||||
$punct_data = substr($sql,$count1,$count2-$count1);
|
$punct_data = substr($sql,$count1,$count2-$count1);
|
||||||
} else {
|
} else {
|
||||||
@@ -262,7 +266,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//check for alpha
|
//check for alpha
|
||||||
if( FALSE && PMA_STR_IsSqlIdentifier($c,FALSE) || ($c == '@')) {
|
if (PMA_STR_IsSqlIdentifier($c,FALSE) || ($c == '@')) {
|
||||||
$count2 ++;
|
$count2 ++;
|
||||||
$is_SQLvariable = ($c == '@');
|
$is_SQLvariable = ($c == '@');
|
||||||
$is_Digit = (!$is_SQLvariable) && PMA_STR_IsDigit($c);
|
$is_Digit = (!$is_SQLvariable) && PMA_STR_IsDigit($c);
|
||||||
@@ -270,20 +274,20 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
$is_FloatDigit = FALSE;
|
$is_FloatDigit = FALSE;
|
||||||
$is_FloatDigitExponent = FALSE;
|
$is_FloatDigitExponent = FALSE;
|
||||||
|
|
||||||
if($is_HexDigit) {
|
if ($is_HexDigit) {
|
||||||
$count2++;
|
$count2++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
while(($count2 < $len) && PMA_STR_IsSqlIdentifier($sql[$count2],$is_SQLvariable || $is_Digit)) {
|
while(($count2 < $len) && PMA_STR_IsSqlIdentifier($sql[$count2],$is_SQLvariable || $is_Digit)) {
|
||||||
$c2 = $sql[$count2];
|
$c2 = $sql[$count2];
|
||||||
if($is_SQLvariable && ($c2 == '.')) {
|
if ($is_SQLvariable && ($c2 == '.')) {
|
||||||
$count2++;
|
$count2++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if($is_Digit && (!$is_HexDigit) && ($c2 == '.')) {
|
if ($is_Digit && (!$is_HexDigit) && ($c2 == '.')) {
|
||||||
$count2++;
|
$count2++;
|
||||||
if(!$is_FloatDigit) {
|
if (!$is_FloatDigit) {
|
||||||
$is_FloatDigit = TRUE;
|
$is_FloatDigit = TRUE;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
@@ -291,8 +295,8 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($is_Digit && (!$is_HexDigit) && (($c2 == 'e') || ($c2 == 'E'))) {
|
if ($is_Digit && (!$is_HexDigit) && (($c2 == 'e') || ($c2 == 'E'))) {
|
||||||
if(!$is_FloatDigitExponent) {
|
if (!$is_FloatDigitExponent) {
|
||||||
$is_FloatDigitExponent = TRUE;
|
$is_FloatDigitExponent = TRUE;
|
||||||
$is_FloatDigit = TRUE;
|
$is_FloatDigit = TRUE;
|
||||||
$count2++;
|
$count2++;
|
||||||
@@ -302,7 +306,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
$is_FloatDigit = FALSE;
|
$is_FloatDigit = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( ($is_HexDigit && PMA_STR_IsHexDigit($c2)) || ($is_Digit && PMA_STR_IsDigit($c2))) {
|
if ( ($is_HexDigit && PMA_STR_IsHexDigit($c2)) || ($is_Digit && PMA_STR_IsDigit($c2))) {
|
||||||
$count2++;
|
$count2++;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
@@ -318,17 +322,17 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
$str = substr($sql,$count1,$l);
|
$str = substr($sql,$count1,$l);
|
||||||
|
|
||||||
$type = '';
|
$type = '';
|
||||||
if($is_Digit) {
|
if ($is_Digit) {
|
||||||
$type = 'digit';
|
$type = 'digit';
|
||||||
if($is_FloatDigit) {
|
if ($is_FloatDigit) {
|
||||||
$type .= '_float';
|
$type .= '_float';
|
||||||
} elseif($is_HexDigit) {
|
} elseif ($is_HexDigit) {
|
||||||
$type .= '_hex';
|
$type .= '_hex';
|
||||||
} else {
|
} else {
|
||||||
$type .= '_integer';
|
$type .= '_integer';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if($is_SQLvariable != FALSE) {
|
if ($is_SQLvariable != FALSE) {
|
||||||
$type = 'alpha_variable';
|
$type = 'alpha_variable';
|
||||||
} else {
|
} else {
|
||||||
$type = 'alpha';
|
$type = 'alpha';
|
||||||
@@ -359,13 +363,10 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
global $syntax_columnAttrib, $syntax_reservedWord, $syntax_columnType, $syntax_functionName;
|
global $PMA_SQPdata_ColumnAttrib, $PMA_SQPdata_ReservedWord, $PMA_SQPdata_ColumnType, $PMA_SQPdata_FunctionName,
|
||||||
$len_columnAttrib = count($syntax_columnAttrib);
|
$PMA_SQPdata_ColumnAttribLen, $PMA_SQPdata_ReservedWordLen, $PMA_SQPdata_ColumnTypeLen, $PMA_SQPdata_FunctionNameLen;
|
||||||
$len_reservedWord = count($syntax_reservedWord);
|
|
||||||
$len_columnType = count($syntax_columnType);
|
|
||||||
$len_functionName = count($syntax_functionName);
|
|
||||||
|
|
||||||
if($arraysize > 0) {
|
if ($arraysize > 0) {
|
||||||
$t_next = $sql_array[0]['type'];
|
$t_next = $sql_array[0]['type'];
|
||||||
$t_prev = NULL;
|
$t_prev = NULL;
|
||||||
}
|
}
|
||||||
@@ -373,23 +374,23 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
for($i = 0; $i < $arraysize; $i++) {
|
for($i = 0; $i < $arraysize; $i++) {
|
||||||
$t_prev = $t_cur;
|
$t_prev = $t_cur;
|
||||||
$t_cur = $t_next;
|
$t_cur = $t_next;
|
||||||
if(($i+1)<$arraysize) {
|
if (($i+1)<$arraysize) {
|
||||||
$t_next = $sql_array[$i+1]['type'];
|
$t_next = $sql_array[$i+1]['type'];
|
||||||
} else {
|
} else {
|
||||||
$t_next = NULL;
|
$t_next = NULL;
|
||||||
}
|
}
|
||||||
if($t_cur == 'alpha') {
|
if ($t_cur == 'alpha') {
|
||||||
$t_suffix = '_identifier';
|
$t_suffix = '_identifier';
|
||||||
$d_cur_upper = strtoupper($sql_array[$i]['data']);
|
$d_cur_upper = strtoupper($sql_array[$i]['data']);
|
||||||
if( ($t_next == 'punct_qualifier') || ($t_prev == 'punct_qualifier')) {
|
if ( ($t_next == 'punct_qualifier') || ($t_prev == 'punct_qualifier')) {
|
||||||
$t_suffix = '_identifier';
|
$t_suffix = '_identifier';
|
||||||
} elseif( ($t_next == 'punct_bracket_open_round') && PMA_STR_BinarySearchInArr($d_cur_upper,$syntax_functionName,$len_functionName)) {
|
} elseif ( ($t_next == 'punct_bracket_open_round') && PMA_STR_BinarySearchInArr($d_cur_upper,$PMA_SQPdata_FunctionName,$PMA_SQPdata_FunctionNameLen)) {
|
||||||
$t_suffix = '_functionName';
|
$t_suffix = '_functionName';
|
||||||
} elseif(PMA_STR_BinarySearchInArr($d_cur_upper,$syntax_reservedWord,$len_reservedWord)) {
|
} elseif (PMA_STR_BinarySearchInArr($d_cur_upper,$PMA_SQPdata_ReservedWord,$PMA_SQPdata_ReservedWordLen)) {
|
||||||
$t_suffix = '_reservedWord';
|
$t_suffix = '_reservedWord';
|
||||||
} elseif(PMA_STR_BinarySearchInArr($d_cur_upper,$syntax_columnType,$len_columnType)) {
|
} elseif (PMA_STR_BinarySearchInArr($d_cur_upper,$PMA_SQPdata_ColumnType,$PMA_SQPdata_ColumnTypeLen)) {
|
||||||
$t_suffix = '_columnType';
|
$t_suffix = '_columnType';
|
||||||
} elseif(PMA_STR_BinarySearchInArr($d_cur_upper,$syntax_columnAttrib,$len_columnAttrib)) {
|
} elseif (PMA_STR_BinarySearchInArr($d_cur_upper,$PMA_SQPdata_ColumnAttrib,$PMA_SQPdata_ColumnAttribLen)) {
|
||||||
$t_suffix = '_columnAttrib';
|
$t_suffix = '_columnAttrib';
|
||||||
} else {
|
} else {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
@@ -407,7 +408,8 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function PMA_SQP_Analyze($arr) {
|
function PMA_SQP_Analyze($arr)
|
||||||
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
$size = $arr['len'];
|
$size = $arr['len'];
|
||||||
$subresult = array(
|
$subresult = array(
|
||||||
@@ -443,8 +445,8 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
|
|
||||||
for($i=0;$i <= $size; $i++) {
|
for($i=0;$i <= $size; $i++) {
|
||||||
// High speed seek for locating the end of the current query
|
// High speed seek for locating the end of the current query
|
||||||
if($seek_queryend == TRUE) {
|
if ($seek_queryend == TRUE) {
|
||||||
if($arr[$i]['type'] == 'punct_queryend') {
|
if ($arr[$i]['type'] == 'punct_queryend') {
|
||||||
$seek_queryend = FALSE;
|
$seek_queryend = FALSE;
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
@@ -458,11 +460,11 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
break;
|
break;
|
||||||
case 'alpha_reservedWord':
|
case 'alpha_reservedWord':
|
||||||
// We don't know what type of query yet, so run this
|
// We don't know what type of query yet, so run this
|
||||||
if($subresult['querytype'] == '') {
|
if ($subresult['querytype'] == '') {
|
||||||
$subresult['querytype'] = strtoupper($arr[$i]['data']);
|
$subresult['querytype'] = strtoupper($arr[$i]['data']);
|
||||||
}
|
}
|
||||||
// Check if we support this type of query
|
// Check if we support this type of query
|
||||||
if(! PMA_STR_BinarySearchInArr($subresult['querytype'],$supportedQueryTypes,$supportedQueryTypes_size)) {
|
if (! PMA_STR_BinarySearchInArr($subresult['querytype'],$supportedQueryTypes,$supportedQueryTypes_size)) {
|
||||||
// Skip ahead to the next one if we don't
|
// Skip ahead to the next one if we don't
|
||||||
$seek_queryend = TRUE;
|
$seek_queryend = TRUE;
|
||||||
}
|
}
|
||||||
@@ -481,7 +483,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// They are are naughty and didn't have a trailing semi-colon, then still handle it properly
|
// They are are naughty and didn't have a trailing semi-colon, then still handle it properly
|
||||||
if($subresult['querytype'] != '') {
|
if ($subresult['querytype'] != '') {
|
||||||
$result[] = $subresult;
|
$result[] = $subresult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -490,10 +492,11 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
echo '</pre>';
|
echo '</pre>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function PMA_SQP_FormatHTML_colorize($arr) {
|
function PMA_SQP_FormatHTML_colorize($arr)
|
||||||
|
{
|
||||||
$i = strpos($arr['type'],'_');
|
$i = strpos($arr['type'],'_');
|
||||||
$class = '';
|
$class = '';
|
||||||
if($i > 0) {
|
if ($i > 0) {
|
||||||
$class = 'syntax_'.substr($arr['type'],0,$i).' ';
|
$class = 'syntax_'.substr($arr['type'],0,$i).' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -501,7 +504,8 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
return '<span class="'.$class.'">'.htmlspecialchars($arr['data']).'</span>';
|
return '<span class="'.$class.'">'.htmlspecialchars($arr['data']).'</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function PMA_SQP_FormatHTML($arr) {
|
function PMA_SQP_FormatHTML($arr)
|
||||||
|
{
|
||||||
$str = '';
|
$str = '';
|
||||||
$indent = 0;
|
$indent = 0;
|
||||||
$bracketlevel = 0;
|
$bracketlevel = 0;
|
||||||
@@ -521,7 +525,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
$keywordsWithBrackets_size = count($keywordsWithBrackets);
|
$keywordsWithBrackets_size = count($keywordsWithBrackets);
|
||||||
$arraysize = $arr['len'];
|
$arraysize = $arr['len'];
|
||||||
$typearr = array();
|
$typearr = array();
|
||||||
if($arraysize >= 0) {
|
if ($arraysize >= 0) {
|
||||||
/* array_push($typearr,NULL);
|
/* array_push($typearr,NULL);
|
||||||
array_push($typearr,NULL);
|
array_push($typearr,NULL);
|
||||||
array_push($typearr,NULL);
|
array_push($typearr,NULL);
|
||||||
@@ -545,7 +549,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
2 current
|
2 current
|
||||||
3 next
|
3 next
|
||||||
*/
|
*/
|
||||||
if(($i+1)<$arraysize) {
|
if (($i+1)<$arraysize) {
|
||||||
//array_push($typearr,$arr[$i+1]['type']);
|
//array_push($typearr,$arr[$i+1]['type']);
|
||||||
$typearr[4] = $arr[$i+1]['type'];
|
$typearr[4] = $arr[$i+1]['type'];
|
||||||
} else {
|
} else {
|
||||||
@@ -566,7 +570,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
$bracketlevel++;
|
$bracketlevel++;
|
||||||
$infunction = FALSE;
|
$infunction = FALSE;
|
||||||
//make sure this array is sorted!
|
//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' ) && ( PMA_STR_BinarySearchInArr(strtoupper($arr[$i-2]['data']),$keywordsWithBrackets,$keywordsWithBrackets_size))) ) {
|
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' ) && ( PMA_STR_BinarySearchInArr(strtoupper($arr[$i-2]['data']),$keywordsWithBrackets,$keywordsWithBrackets_size))) ) {
|
||||||
$functionlevel++;
|
$functionlevel++;
|
||||||
$infunction = TRUE;
|
$infunction = TRUE;
|
||||||
$after .= ' ';
|
$after .= ' ';
|
||||||
@@ -578,14 +582,14 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
case 'punct_qualifier':
|
case 'punct_qualifier':
|
||||||
break;
|
break;
|
||||||
case 'punct_listsep':
|
case 'punct_listsep':
|
||||||
if($infunction == TRUE) {
|
if ($infunction == TRUE) {
|
||||||
$after .= $space_punct_listsep_functionName;
|
$after .= $space_punct_listsep_functionName;
|
||||||
} else {
|
} else {
|
||||||
$after .= $space_punct_listsep;
|
$after .= $space_punct_listsep;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'punct_queryend':
|
case 'punct_queryend':
|
||||||
if(($typearr[3] != 'white_newline') && ($typearr[3] != 'comment_mysql')&& ($typearr[3] != 'comment_ansi') ) {
|
if (($typearr[3] != 'white_newline') && ($typearr[3] != 'comment_mysql')&& ($typearr[3] != 'comment_ansi') ) {
|
||||||
$after .= '<br />'."\n";
|
$after .= '<br />'."\n";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -593,7 +597,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
break;
|
break;
|
||||||
case 'punct_bracket_close_round':
|
case 'punct_bracket_close_round':
|
||||||
$bracketlevel--;
|
$bracketlevel--;
|
||||||
if($infunction == TRUE) {
|
if ($infunction == TRUE) {
|
||||||
$functionlevel--;
|
$functionlevel--;
|
||||||
$after .= ' ';
|
$after .= ' ';
|
||||||
} else {
|
} else {
|
||||||
@@ -604,7 +608,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'alpha_reservedWord':
|
case 'alpha_reservedWord':
|
||||||
if( ($typearr[1] != 'alpha_reservedWord') && ($typearr[1] != 'punct_level_plus') && ($typearr[1] != 'white_newline')) {
|
if ( ($typearr[1] != 'alpha_reservedWord') && ($typearr[1] != 'punct_level_plus') && ($typearr[1] != 'white_newline')) {
|
||||||
$before .= $space_alpha_reservedWord;
|
$before .= $space_alpha_reservedWord;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -640,7 +644,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($typearr[3] != 'punct_qualifier') {
|
if ($typearr[3] != 'punct_qualifier') {
|
||||||
$after .= ' ';
|
$after .= ' ';
|
||||||
}
|
}
|
||||||
$str .= $before.PMA_SQP_FormatHTML_colorize($arr[$i]).$after;
|
$str .= $before.PMA_SQP_FormatHTML_colorize($arr[$i]).$after;
|
||||||
|
Reference in New Issue
Block a user