MySQL  8.0.17
Source Code Documentation
sql_lex.cc File Reference
#include "sql/sql_lex.h"
#include <limits.h>
#include <stdlib.h>
#include <algorithm>
#include "m_ctype.h"
#include "my_alloc.h"
#include "my_dbug.h"
#include "my_macros.h"
#include "mysql/mysql_lex_string.h"
#include "mysql/service_mysql_alloc.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/mysqld.h"
#include "sql/nested_join.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_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 "template_utils.h"

Macros

#define UNSAFE(a, b, c)
 

Typedefs

typedef Prealloced_array< TABLE_LIST *, 8 > Table_array
 

Functions

int HINT_PARSER_parse (THD *thd, Hint_scanner *scanner, PT_hint_list **ret)
 
static int lex_one_token (Lexer_yystype *yylval, THD *thd)
 
bool lex_init (void)
 
void lex_free (void)
 
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 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 MYSQLlex (YYSTYPE *yacc_yylval, YYLTYPE *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...
 
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, List< TABLE_LIST > *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 (List< TABLE_LIST > *tables, Select_lex_visitor *visitor)
 
bool accept_table (TABLE_LIST *t, Select_lex_visitor *visitor)
 
static bool get_optimizable_join_conditions (THD *thd, List< TABLE_LIST > &join_list)
 Helper function which handles the "ON conditions" part of SELECT_LEX::get_optimizable_conditions(). More...
 
static bool walk_join_condition (List< TABLE_LIST > *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 ()
 

Variables

sys_vartrg_new_row_fake_var = (sys_var *)0x01
 
const LEX_STRING null_lex_str = {NULL, 0}
 LEX_STRING constant for null-string to be used in parser and other places. More...
 
const LEX_STRING empty_lex_str = {(char *)"", 0}
 
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:2335

Typedef Documentation

◆ Table_array

Function Documentation

◆ accept_for_join()

bool accept_for_join ( List< TABLE_LIST > *  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_LIST 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_optimizable_join_conditions()

static bool get_optimizable_join_conditions ( THD thd,
List< TABLE_LIST > &  join_list 
)
static

Helper function which handles the "ON conditions" part of SELECT_LEX::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_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

◆ HINT_PARSER_parse()

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

◆ 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

◆ print_join()

static void print_join ( const THD thd,
String str,
List< TABLE_LIST > *  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_table_array()

static void print_table_array ( const THD thd,
String str,
const Table_array tables,
enum_query_type  query_type 
)
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 ( List< TABLE_LIST > *  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