@@ -278,30 +278,31 @@ public static function parse(Parser $parser, TokensList $list, array $options =
278278 } elseif (($ token ->value === ', ' ) && ($ brackets === 0 )) {
279279 break ;
280280 }
281- } elseif (! empty (Parser::$ STATEMENT_PARSERS [$ token ->value ])) {
282- // We have reached the end of ALTER operation and suddenly found
283- // a start to new statement, but have not find a delimiter between them
284-
285- if (! ($ token ->value === 'SET ' && $ list ->tokens [$ list ->idx - 1 ]->value === 'CHARACTER ' )) {
281+ } elseif (! self ::checkIfTokenQuotedSymbol ($ token )) {
282+ if (! empty (Parser::$ STATEMENT_PARSERS [$ token ->value ])) {
283+ // We have reached the end of ALTER operation and suddenly found
284+ // a start to new statement, but have not find a delimiter between them
285+
286+ if (! ($ token ->value === 'SET ' && $ list ->tokens [$ list ->idx - 1 ]->value === 'CHARACTER ' )) {
287+ $ parser ->error (
288+ 'A new statement was found, but no delimiter between it and the previous one. ' ,
289+ $ token
290+ );
291+ break ;
292+ }
293+ } elseif ((array_key_exists ($ array_key , self ::$ DB_OPTIONS )
294+ || array_key_exists ($ array_key , self ::$ TABLE_OPTIONS ))
295+ && ! self ::checkIfColumnDefinitionKeyword ($ array_key )
296+ ) {
297+ // This alter operation has finished, which means a comma
298+ // was missing before start of new alter operation
286299 $ parser ->error (
287- 'A new statement was found, but no delimiter between it and the previous one . ' ,
300+ 'Missing comma before start of a new alter operation . ' ,
288301 $ token
289302 );
290303 break ;
291304 }
292- } elseif ((array_key_exists ($ array_key , self ::$ DB_OPTIONS )
293- || array_key_exists ($ array_key , self ::$ TABLE_OPTIONS ))
294- && ! self ::checkIfColumnDefinitionKeyword ($ array_key )
295- ) {
296- // This alter operation has finished, which means a comma
297- // was missing before start of new alter operation
298- $ parser ->error (
299- 'Missing comma before start of a new alter operation. ' ,
300- $ token
301- );
302- break ;
303305 }
304-
305306 $ ret ->unknown [] = $ token ;
306307 }
307308 }
@@ -362,4 +363,16 @@ private static function checkIfColumnDefinitionKeyword($tokenValue)
362363 // both table as well as a specific column in the table
363364 return in_array ($ tokenValue , $ common_options );
364365 }
366+
367+ /**
368+ * Check if token is symbol and quoted with backtick
369+ *
370+ * @param Token $token token to check
371+ *
372+ * @return bool
373+ */
374+ private static function checkIfTokenQuotedSymbol ($ token )
375+ {
376+ return $ token ->type === Token::TYPE_SYMBOL && $ token ->flags === Token::FLAG_SYMBOL_BACKTICK ;
377+ }
365378}
0 commit comments