MySQL 8.4.2
Source Code Documentation
Hint_scanner Class Reference

Lexical scanner for hint comments. More...

#include <sql_lex_hints.h>

Public Member Functions

 Hint_scanner (THD *thd, size_t lineno_arg, const char *buf, size_t len, sql_digest_state *digest_state_arg)
 Constructor. More...
 
size_t get_lineno () const
 
const char * get_ptr () const
 
sql_digest_stateget_digest ()
 
void syntax_warning (const char *msg) const
 Push a warning message into MySQL error stack with line and position information. More...
 
int get_next_token ()
 

Public Attributes

const char * raw_yytext
 Current token (yytext) origin in the input_buf. More...
 
const char * yytext
 Current token pointer (may be converted allocated string outside input_buf. More...
 
size_t yyleng
 Length of the current token (see yytext) More...
 
bool has_hints
 True if a hint comment is not empty (has any hints). More...
 

Protected Member Functions

int scan ()
 
template<hint_lex_char_classes Quote>
int scan_quoted ()
 
int scan_ident ()
 
int scan_multiplier_or_ident ()
 
int scan_query_block_name ()
 
int scan_ident_or_keyword ()
 
int scan_number_or_multiplier_or_ident ()
 
int scan_fraction_digits ()
 
bool eof () const
 
char peek_byte () const
 
hint_lex_char_classes peek_class () const
 
hint_lex_char_classes peek_class2 () const
 
void skip_newline ()
 
uchar get_byte ()
 
void skip_byte ()
 
void skip_byte (char byte)
 Skips the next byte. More...
 
void skip_byte (const char *str)
 Skips the next byte. More...
 
bool skip_mb ()
 
void adjust_token ()
 
void start_token ()
 
template<hint_lex_char_classes Separator>
void compact (LEX_STRING *to, const char *from, size_t len, size_t doubles)
 
void add_hint_token_digest ()
 Add hint tokens to main lexer's digest calculation buffer. More...
 

Private Member Functions

void add_digest (uint token)
 Helper function to check digest buffer for overflow before adding tokens. More...
 

Private Attributes

THDthd
 
const CHARSET_INFOcs
 
const bool is_ansi_quotes
 
size_t lineno
 
const hint_lex_char_classeschar_classes
 
const char * input_buf
 
const char * input_buf_end
 
const char * ptr
 
int prev_token
 
sql_digest_statedigest_state
 Digest buffer interface to append tokens. More...
 

Detailed Description

Lexical scanner for hint comments.

When the main lexical scanner recognizes the "/*+" delimiter, it calls the hint parser (my_hint_parser_parse) to consume the rest of hint tokens including the *‍/ delimiter. The hint parser uses Hint_scanner as its own lexer to scan hint-specific tokens.

Constructor & Destructor Documentation

◆ Hint_scanner()

Hint_scanner::Hint_scanner ( THD thd_arg,
size_t  lineno_arg,
const char *  buf,
size_t  len,
sql_digest_state digest_state_arg 
)

Constructor.

Parameters
thd_argThe thread handler.
lineno_argThe starting line number of a hint string in a query.
bufThe rest of a query buffer with hints at the start.
lenThe length of the buf.
digest_state_argThe digest buffer to output scanned token data.

Member Function Documentation

◆ add_digest()

void Hint_scanner::add_digest ( uint  token)
inlineprivate

Helper function to check digest buffer for overflow before adding tokens.

Parameters
tokenA token number to add.

◆ add_hint_token_digest()

void Hint_scanner::add_hint_token_digest ( )
protected

Add hint tokens to main lexer's digest calculation buffer.

◆ adjust_token()

void Hint_scanner::adjust_token ( )
inlineprotected

◆ compact()

template<hint_lex_char_classes Separator>
void Hint_scanner::compact ( LEX_STRING to,
const char *  from,
size_t  len,
size_t  doubles 
)
inlineprotected

◆ eof()

bool Hint_scanner::eof ( ) const
inlineprotected

◆ get_byte()

uchar Hint_scanner::get_byte ( )
inlineprotected

◆ get_digest()

sql_digest_state * Hint_scanner::get_digest ( )
inline

◆ get_lineno()

size_t Hint_scanner::get_lineno ( ) const
inline

◆ get_next_token()

int Hint_scanner::get_next_token ( )
inline

◆ get_ptr()

const char * Hint_scanner::get_ptr ( ) const
inline

◆ peek_byte()

char Hint_scanner::peek_byte ( ) const
inlineprotected

◆ peek_class()

hint_lex_char_classes Hint_scanner::peek_class ( ) const
inlineprotected

◆ peek_class2()

hint_lex_char_classes Hint_scanner::peek_class2 ( ) const
inlineprotected

◆ scan()

int Hint_scanner::scan ( )
protected

◆ scan_fraction_digits()

int Hint_scanner::scan_fraction_digits ( )
inlineprotected

◆ scan_ident()

int Hint_scanner::scan_ident ( )
inlineprotected

◆ scan_ident_or_keyword()

int Hint_scanner::scan_ident_or_keyword ( )
inlineprotected

◆ scan_multiplier_or_ident()

int Hint_scanner::scan_multiplier_or_ident ( )
inlineprotected

◆ scan_number_or_multiplier_or_ident()

int Hint_scanner::scan_number_or_multiplier_or_ident ( )
inlineprotected

◆ scan_query_block_name()

int Hint_scanner::scan_query_block_name ( )
inlineprotected

◆ scan_quoted()

template<hint_lex_char_classes Quote>
int Hint_scanner::scan_quoted ( )
inlineprotected

◆ skip_byte() [1/3]

void Hint_scanner::skip_byte ( )
inlineprotected

◆ skip_byte() [2/3]

void Hint_scanner::skip_byte ( char  byte)
inlineprotected

Skips the next byte.

In the debug mode, abort if it's not found in byte.

Parameters
byteA byte to compare with the byte we skip. Unused in non-debug builds.

◆ skip_byte() [3/3]

void Hint_scanner::skip_byte ( const char *  str)
inlineprotected

Skips the next byte.

In the debug mode, abort if it's not found in str.

Parameters
strA string of characters to compare with the next byte. Unused in non-debug builds.

◆ skip_mb()

bool Hint_scanner::skip_mb ( )
inlineprotected

◆ skip_newline()

void Hint_scanner::skip_newline ( )
inlineprotected

◆ start_token()

void Hint_scanner::start_token ( )
inlineprotected

◆ syntax_warning()

void Hint_scanner::syntax_warning ( const char *  msg) const

Push a warning message into MySQL error stack with line and position information.

This function provides semantic action implementers with a way to push the famous "You have a syntax error near..." error message into the error stack, which is normally produced only if a parse error is discovered internally by the Bison generated parser.

Member Data Documentation

◆ char_classes

const hint_lex_char_classes* Hint_scanner::char_classes
private

◆ cs

const CHARSET_INFO* Hint_scanner::cs
private

◆ digest_state

sql_digest_state* Hint_scanner::digest_state
private

Digest buffer interface to append tokens.

◆ has_hints

bool Hint_scanner::has_hints

True if a hint comment is not empty (has any hints).

◆ input_buf

const char* Hint_scanner::input_buf
private

◆ input_buf_end

const char* Hint_scanner::input_buf_end
private

◆ is_ansi_quotes

const bool Hint_scanner::is_ansi_quotes
private

◆ lineno

size_t Hint_scanner::lineno
private

◆ prev_token

int Hint_scanner::prev_token
private

◆ ptr

const char* Hint_scanner::ptr
private

◆ raw_yytext

const char* Hint_scanner::raw_yytext

Current token (yytext) origin in the input_buf.

◆ thd

THD* Hint_scanner::thd
private

◆ yyleng

size_t Hint_scanner::yyleng

Length of the current token (see yytext)

◆ yytext

const char* Hint_scanner::yytext

Current token pointer (may be converted allocated string outside input_buf.


The documentation for this class was generated from the following files: