MySQL  8.0.27
Source Code Documentation
anonymous_namespace{item_strfunc.cc} Namespace Reference

Classes

class  Thd_parse_modifier
 Because it's not possible to disentangle the state of the parser from the THD, we have to destructively modify the current THD object in order to parse. More...
 
class  Parse_error_anonymizer
 Error handler that wraps parse error messages, removes details and silences warnings. More...
 

Functions

bool parse (THD *thd, Item *statement_expr, String *statement_string)
 Parses a string and fills the token buffer. More...
 

Function Documentation

◆ parse()

bool anonymous_namespace{item_strfunc.cc}::parse ( THD thd,
Item statement_expr,
String statement_string 
)

Parses a string and fills the token buffer.

The parser function THD::sql_parser() is called directly instead of parse_sql(), as the latter assumes that it is called with the intent to record the statement in performance_schema and later execute it, neither of which is called for here. In fact we hardly need the parser to calculate a digest, since it is calculated from the token stream. There are only some corner cases where NULL is sometimes a literal and sometimes an operator, as in IS NULL, IS NOT NULL.

Parameters
thdSession object used by the parser.
statement_exprThe expression that evaluates to something that can be parsed. Needed for error messages in case we don't want to disclose what it evaluates to.
statement_stringThe non-NULL string resulting from evaluating statement_expr. The caller is preferred to do this as this function doesn't deal with NULL values.
Return values
trueError.
falseAll went well, the digest information is in THD::m_digest.