• Alexander Barkov's avatar
    MDEV-33281 Implement optimizer hints · 189c8eb9
    Alexander Barkov authored
    - Using Lex_ident_sys to scan identifiers, like the SQL parser does.
    
      This fixes handling of double-quote-delimited and backtick-delimited identifiers,
      as well as handling of non-ASCII identifiers.
    
      Unescaping and converting from the client character set to the system
      character set is now done using Lex_ident_cli_st and Lex_ident_sys,
      like it's done in the SQL tokenizer/parser.
      Adding helper methods to_ident_cli() and to_ident_sys()
      in Optimizer_hint_parser::Token.
    
    - Fixing the hint parser to report a syntax error when an empty identifiers:
        SELECT /*+ BKA(``) */ * FROM t1;
    
    - Moving a part of the code from opt_hints_parser.h to opt_hints_parser.cc
    
      Moving these method definitions:
      - Optimizer_hint_tokenizer::find_keyword()
      - Optimizer_hint_tokenizer::get_token()
    
      to avoid huge pieces of the code in the header file.
    
    - A Lex_ident_cli_st cleanup
      Fixing a few Lex_ident_cli_st methods to return Lex_ident_cli_st &
      instead of void, to use them easier in the caller code.
    
    - Fixing the hint parser to display the correct line number
    
      Adding a new data type Lex_comment_st
      (a combination of LEX_CSTRING and a line number)
      Using it in sql_yacc.yy
    
    - Getting rid of redundant dependencies on sql_hints_parser.h
    
      Moving void LEX::resolve_optimizer_hints() from sql_lex.h to sql_lex.cc
    
      Adding a class Optimizer_hint_parser_output, deriving from
      Optimizer_hint_parser::Hint_list. Fixing the hint parser to
      return a pointer to an allocated instance of Optimizer_hint_parser_output
      rather than an instance of Optimizer_hint_parser::Hint_list.
      This allows to use a forward declaration of Optimizer_hint_parser_output
      in sql_lex.h and thus avoid dependencies on sql_hints_parser.h.
    189c8eb9
sql_lex.h 169 KB