MySQL 8.4.2
Source Code Documentation
sql_lex.cc File Reference
#include "sql/sql_lex.h"
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <initializer_list>
#include <memory>
#include "field_types.h"
#include "m_string.h"
#include "my_alloc.h"
#include "my_dbug.h"
#include "mysql/mysql_lex_string.h"
#include "mysql/service_mysql_alloc.h"
#include "mysql/strings/collations.h"
#include "mysql/strings/m_ctype.h"
#include "mysql_version.h"
#include "mysqld_error.h"
#include "prealloced_array.h"
#include "sql/current_thd.h"
#include "sql/derror.h"
#include "sql/item_func.h"
#include "sql/item_subselect.h"
#include "sql/lex_symbol.h"
#include "sql/lexer_yystype.h"
#include "sql/mysqld.h"
#include "sql/nested_join.h"
#include "sql/opt_hints.h"
#include "sql/parse_location.h"
#include "sql/parse_tree_nodes.h"
#include "sql/protocol.h"
#include "sql/select_lex_visitor.h"
#include "sql/sp_head.h"
#include "sql/sql_admin.h"
#include "sql/sql_base.h"
#include "sql/sql_class.h"
#include "sql/sql_cmd.h"
#include "sql/sql_digest_stream.h"
#include "sql/sql_error.h"
#include "sql/sql_insert.h"
#include "sql/sql_lex_hash.h"
#include "sql/sql_lex_hints.h"
#include "sql/sql_optimizer.h"
#include "sql/sql_parse.h"
#include "sql/sql_plugin.h"
#include "sql/sql_profile.h"
#include "sql/sql_show.h"
#include "sql/sql_table.h"
#include "sql/sql_yacc.h"
#include "sql/system_variables.h"
#include "sql/table_function.h"
#include "sql/window.h"
#include "sql_update.h"
#include "string_with_len.h"
#include "template_utils.h"

Macros

#define UNSAFE(a, b, c)
 

Typedefs

typedef Prealloced_array< Table_ref *, 8 > Table_array
 

Functions

int my_hint_parser_parse (THD *thd, Hint_scanner *scanner, PT_hint_list **ret)
 
static int lex_one_token (Lexer_yystype *yylval, THD *thd)
 
void lex_free ()
 
bool lex_start (THD *thd)
 Call lex_start() before every query that is to be prepared and executed. More...
 
void lex_end (LEX *lex)
 Call this function after preparation and execution of a query. More...
 
static bool consume_optimizer_hints (Lex_input_stream *lip)
 
static int find_keyword (Lex_input_stream *lip, uint len, bool function)
 
bool is_keyword (const char *name, size_t len)
 
bool is_lex_native_function (const LEX_STRING *name)
 Check if name is a sql function. More...
 
static LEX_STRING get_token (Lex_input_stream *lip, uint skip, uint length)
 
static LEX_STRING get_quoted_token (Lex_input_stream *lip, uint skip, uint length, char quote)
 
static char * get_text (Lex_input_stream *lip, int pre_skip, int post_skip)
 
static LEX_CSTRING get_dollar_quoted_text (Lex_input_stream *lip, int tag_len)
 Get the text literal between dollar quotes. More...
 
static uint int_token (const char *str, uint length)
 
static bool consume_comment (Lex_input_stream *lip, int remaining_recursions_permitted)
 Given a stream that is advanced to the first contained character in an open comment, consume the comment. More...
 
int my_sql_parser_lex (MY_SQL_PARSER_STYPE *yacc_yylval, POS *yylloc, THD *thd)
 yylex() function implementation for the main parser More...
 
void trim_whitespace (const CHARSET_INFO *cs, LEX_STRING *str)
 
void print_derived_column_names (const THD *thd, String *str, const Create_col_name_list *column_names)
 Prints into 'str' a comma-separated list of column names, enclosed in parenthesis. More...
 
void print_set_operation (const THD *thd, Query_term *op, String *str, int level, enum_query_type query_type)
 
static void print_table_array (const THD *thd, String *str, const Table_array &tables, enum_query_type query_type)
 
static void print_join (const THD *thd, String *str, mem_root_deque< Table_ref * > *tables, enum_query_type query_type)
 Print joins from the FROM clause. More...
 
bool db_is_default_db (const char *db, size_t db_len, const THD *thd)
 
static enum_walk get_walk_flags (const Select_lex_visitor *visitor)
 
bool walk_item (Item *item, Select_lex_visitor *visitor)
 
bool accept_for_order (SQL_I_List< ORDER > orders, Select_lex_visitor *visitor)
 
bool accept_for_join (mem_root_deque< Table_ref * > *tables, Select_lex_visitor *visitor)
 
bool accept_table (Table_ref *t, Select_lex_visitor *visitor)
 
static enum_explain_type setop2result (Query_term *qt)
 
static bool get_optimizable_join_conditions (THD *thd, mem_root_deque< Table_ref * > &join_list)
 Helper function which handles the "ON conditions" part of Query_block::get_optimizable_conditions(). More...
 
static bool walk_join_condition (mem_root_deque< Table_ref * > *tables, Item_processor processor, enum_walk walk, uchar *arg)
 Apply walk() processor to join conditions. More...
 
static void unsafe_mixed_statement (LEX::enum_stmt_accessed_table a, LEX::enum_stmt_accessed_table b, uint condition)
 
void binlog_unsafe_map_init ()
 
void get_select_options_str (ulonglong options, std::string *str)
 

Variables

const LEX_STRING null_lex_str = {nullptr, 0}
 LEX_STRING constant for null-string to be used in parser and other places. More...
 
const char * index_hint_type_name []
 
static const char * long_str = "2147483647"
 
static const uint long_len = 10
 
static const char * signed_long_str = "-2147483648"
 
static const char * longlong_str = "9223372036854775807"
 
static const uint longlong_len = 19
 
static const char * signed_longlong_str = "-9223372036854775808"
 
static const uint signed_longlong_len = 19
 
static const char * unsigned_longlong_str = "18446744073709551615"
 
static const uint unsigned_longlong_len = 20
 
uint binlog_unsafe_map [256]
 

Macro Definition Documentation

◆ UNSAFE

#define UNSAFE (   a,
  b,
 
)
Value:
{ \
DBUG_PRINT("unsafe_mixed_statement", \
("SETTING BASE VALUES: %s, %s, %02X\n", \
unsafe_mixed_statement(a, b, c); \
}
static const char * stmt_accessed_table_string(enum_stmt_accessed_table accessed_table)
Definition: sql_lex.h:3019

Typedef Documentation

◆ Table_array

Function Documentation

◆ accept_for_join()

bool accept_for_join ( mem_root_deque< Table_ref * > *  tables,
Select_lex_visitor visitor 
)

◆ accept_for_order()

bool accept_for_order ( SQL_I_List< ORDER orders,
Select_lex_visitor visitor 
)

◆ accept_table()

bool accept_table ( Table_ref t,
Select_lex_visitor visitor 
)

◆ consume_comment()

static bool consume_comment ( Lex_input_stream lip,
int  remaining_recursions_permitted 
)
static

Given a stream that is advanced to the first contained character in an open comment, consume the comment.

Optionally, if we are allowed, recurse so that we understand comments within this current comment.

At this level, we do not support version-condition comments. We might have been called with having just passed one in the stream, though. In that case, we probably want to tolerate mundane comments inside. Thus, the case for recursion.

Return values
WhetherEOF reached before comment is closed.

◆ consume_optimizer_hints()

static bool consume_optimizer_hints ( Lex_input_stream lip)
static

◆ find_keyword()

static int find_keyword ( Lex_input_stream lip,
uint  len,
bool  function 
)
static

◆ get_dollar_quoted_text()

static LEX_CSTRING get_dollar_quoted_text ( Lex_input_stream lip,
int  tag_len 
)
static

Get the text literal between dollar quotes.

A dollar quote is of the form $tag$, where tag is zero or more characters. The same characters that are permitted for unquoted identifiers, except dollar, may be used for the tag. That is, basic ASCII letters, digits 0-9, underscore, and any multibyte UTF8 characters.

Parameters
lipThe input stream. When called, the current position is right after the initial dollar character
tag_lenThe length of the tag
Returns
The text literal without dollar quotes

◆ get_optimizable_join_conditions()

static bool get_optimizable_join_conditions ( THD thd,
mem_root_deque< Table_ref * > &  join_list 
)
static

Helper function which handles the "ON conditions" part of Query_block::get_optimizable_conditions().

Returns
true if OOM

◆ get_quoted_token()

static LEX_STRING get_quoted_token ( Lex_input_stream lip,
uint  skip,
uint  length,
char  quote 
)
static

◆ get_select_options_str()

void get_select_options_str ( ulonglong  options,
std::string *  str 
)

◆ get_text()

static char * get_text ( Lex_input_stream lip,
int  pre_skip,
int  post_skip 
)
static

◆ get_token()

static LEX_STRING get_token ( Lex_input_stream lip,
uint  skip,
uint  length 
)
static

◆ get_walk_flags()

static enum_walk get_walk_flags ( const Select_lex_visitor visitor)
static

◆ int_token()

static uint int_token ( const char *  str,
uint  length 
)
inlinestatic

◆ lex_one_token()

static int lex_one_token ( Lexer_yystype yylval,
THD thd 
)
static

◆ my_hint_parser_parse()

int my_hint_parser_parse ( THD thd,
Hint_scanner scanner,
PT_hint_list **  ret 
)

◆ print_join()

static void print_join ( const THD thd,
String str,
mem_root_deque< Table_ref * > *  tables,
enum_query_type  query_type 
)
static

Print joins from the FROM clause.

Parameters
thdthread handler
strstring where table should be printed
tableslist of tables in join
query_typetype of the query is being generated

◆ print_set_operation()

void print_set_operation ( const THD thd,
Query_term op,
String str,
int  level,
enum_query_type  query_type 
)

◆ print_table_array()

static void print_table_array ( const THD thd,
String str,
const Table_array tables,
enum_query_type  query_type 
)
static

◆ setop2result()

static enum_explain_type setop2result ( Query_term qt)
static

◆ unsafe_mixed_statement()

static void unsafe_mixed_statement ( LEX::enum_stmt_accessed_table  a,
LEX::enum_stmt_accessed_table  b,
uint  condition 
)
static

◆ walk_item()

bool walk_item ( Item item,
Select_lex_visitor visitor 
)

◆ walk_join_condition()

static bool walk_join_condition ( mem_root_deque< Table_ref * > *  tables,
Item_processor  processor,
enum_walk  walk,
uchar arg 
)
static

Apply walk() processor to join conditions.

JOINs may be nested. Walk nested joins recursively to apply the processor.

Variable Documentation

◆ long_len

const uint long_len = 10
static

◆ long_str

const char* long_str = "2147483647"
static

◆ longlong_len

const uint longlong_len = 19
static

◆ longlong_str

const char* longlong_str = "9223372036854775807"
static

◆ signed_long_str

const char* signed_long_str = "-2147483648"
static

◆ signed_longlong_len

const uint signed_longlong_len = 19
static

◆ signed_longlong_str

const char* signed_longlong_str = "-9223372036854775808"
static

◆ unsigned_longlong_len

const uint unsigned_longlong_len = 20
static

◆ unsigned_longlong_str

const char* unsigned_longlong_str = "18446744073709551615"
static