Skip to content

Commit 841e09a

Browse files
committed
added some more checks to avoid php warnings.
fixed a typo in function call name
1 parent c2a258a commit 841e09a

1 file changed

Lines changed: 18 additions & 12 deletions

File tree

lib_sql_parser.php

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -794,8 +794,10 @@ function _extract_tokens($sql, &$source_map){
794794
}
795795

796796
function parse_index_type(&$tokens, &$index){
797-
if ($tokens[0] == 'USING BTREE'){ $index['mode'] = 'btree'; array_shift($tokens); }
798-
if ($tokens[0] == 'USING HASH' ){ $index['mode'] = 'hash'; array_shift($tokens); }
797+
if (count($tokens) >= 1){
798+
if ($tokens[0] == 'USING BTREE'){ $index['mode'] = 'btree'; array_shift($tokens); }
799+
if ($tokens[0] == 'USING HASH' ){ $index['mode'] = 'hash'; array_shift($tokens); }
800+
}
799801
}
800802

801803
function parse_index_columns(&$tokens, &$index){
@@ -849,19 +851,23 @@ function parse_index_options(&$tokens, &$index){
849851
# | index_type
850852
# | WITH PARSER parser_name
851853

852-
if ($tokens[0] == 'KEY_BLOCK_SIZE'){
853-
array_shift($tokens);
854-
if ($tokens[0] == '=') array_shift($tokens);
855-
$index['key_block_size'] = $tokens[0];
856-
array_shift($tokens);
854+
if (count($tokens) >= 1){
855+
if ($tokens[0] == 'KEY_BLOCK_SIZE'){
856+
array_shift($tokens);
857+
if ($tokens[0] == '=') array_shift($tokens);
858+
$index['key_block_size'] = $tokens[0];
859+
array_shift($tokens);
860+
}
857861
}
858862

859863
$this->parse_index_type($tokens, $index);
860864

861-
if ($tokens[0] == 'WITH PARSER'){
862-
$index['parser'] = $tokens[1];
863-
array_shift($tokens);
864-
array_shift($tokens);
865+
if (count($tokens) >= 1){
866+
if ($tokens[0] == 'WITH PARSER'){
867+
$index['parser'] = $tokens[1];
868+
array_shift($tokens);
869+
array_shift($tokens);
870+
}
865871
}
866872
}
867873

@@ -881,7 +887,7 @@ function parse_field_length(&$tokens, &$f){
881887
}
882888
}
883889

884-
function parse_field_length_deciamsl(&$tokens, &$f){
890+
function parse_field_length_decimals(&$tokens, &$f){
885891
if (count($tokens) >= 5){
886892
if ($tokens[0] == '(' && $tokens[2] == ',' && $tokens[4] == ')'){
887893
$f['length'] = $tokens[1];

0 commit comments

Comments
 (0)