MySQL 9.1.0
Source Code Documentation
sql_lex.h File Reference
#include <string.h>
#include <sys/types.h>
#include <algorithm>
#include <cstdint>
#include <cstring>
#include <functional>
#include <map>
#include <memory>
#include <new>
#include <string>
#include <utility>
#include "lex_string.h"
#include "map_helpers.h"
#include "mem_root_deque.h"
#include "memory_debugging.h"
#include "my_alloc.h"
#include "my_base.h"
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_sqlcommand.h"
#include "my_sys.h"
#include "my_table_map.h"
#include "my_thread_local.h"
#include "mysql/components/services/bits/psi_bits.h"
#include "mysql/service_mysql_alloc.h"
#include "mysql/strings/m_ctype.h"
#include "mysql_com.h"
#include "mysqld_error.h"
#include "prealloced_array.h"
#include "sql/dd/info_schema/table_stats.h"
#include "sql/dd/info_schema/tablespace_stats.h"
#include "sql/enum_query_type.h"
#include "sql/handler.h"
#include "sql/item.h"
#include "sql/item_subselect.h"
#include "sql/iterators/row_iterator.h"
#include "sql/join_optimizer/access_path.h"
#include "sql/join_optimizer/materialize_path_parameters.h"
#include "sql/key_spec.h"
#include "sql/mdl.h"
#include "sql/mem_root_array.h"
#include "sql/parse_location.h"
#include "sql/parse_tree_node_base.h"
#include "sql/parser_yystype.h"
#include "sql/query_options.h"
#include "sql/query_term.h"
#include "sql/set_var.h"
#include "sql/sql_array.h"
#include "sql/sql_connect.h"
#include "sql/sql_const.h"
#include "sql/sql_data_change.h"
#include "sql/sql_error.h"
#include "sql/sql_list.h"
#include "sql/sql_plugin_ref.h"
#include "sql/sql_servers.h"
#include "sql/sql_udf.h"
#include "sql/table.h"
#include "sql/thr_malloc.h"
#include "sql/trigger_def.h"
#include "sql/visible_fields.h"
#include "sql_string.h"
#include "string_with_len.h"
#include "strings/sql_chars.h"
#include "thr_lock.h"
#include "violite.h"

Go to the source code of this file.

Classes

class  Table_ident
 
struct  LEX_SOURCE_INFO
 Structure to hold parameters for CHANGE REPLICATION SOURCE, START REPLICA, and STOP REPLICA. More...
 
struct  LEX_RESET_REPLICA
 
class  Index_hint
 
class  Query_expression
 This class represents a query expression (one query block or several query blocks combined with UNION). More...
 
class  Query_block
 This class represents a query block, aka a query specification, which is a query consisting of a SELECT keyword, followed by a table list, optionally followed by a WHERE clause, a GROUP BY, etc. More...
 
class  Condition_context
 Utility RAII class to save/modify/restore the condition_context information of a query block. More...
 
class  Secondary_engine_execution_context
 Base class for secondary engine execution context objects. More...
 
struct  struct_replica_connection
 
struct  st_sp_chistics
 
struct  st_trg_chistics
 
class  Query_tables_list
 
struct  st_parsing_options
 
class  Lex_input_stream
 This class represents the character input stream consumed during lexical analysis. More...
 
class  LEX_COLUMN
 
class  LEX_GRANT_AS
 
struct  LEX
 The LEX object currently serves three different purposes: More...
 
class  LEX::Splitting_window_expression
 RAII class to set state m_splitting_window_expression for a scope. More...
 
class  Prepare_error_tracker
 RAII class to ease the call of LEX::mark_broken() if error. More...
 
class  Yacc_state
 The internal state of the syntax parser. More...
 
struct  Parser_input
 Input parameters to the parser. More...
 
class  Parser_state
 Internal state of the parser. More...
 
class  Partition_expr_parser_state
 Parser state for partition expression parser (.frm/DD stuff) More...
 
class  Gcol_expr_parser_state
 Parser state for generated column expression parser (.frm/DD stuff) More...
 
class  Expression_parser_state
 Parser state for single expression parser (.frm/DD stuff) More...
 
class  Common_table_expr_parser_state
 Parser state for CTE subquery parser. More...
 
class  Derived_expr_parser_state
 Parser state for Derived table's condition parser. More...
 
struct  st_lex_local
 
class  Change_current_query_block
 RAII class to automate saving/restoring of current_query_block() More...
 

Macros

#define TYPE_ENUM_FUNCTION   1
 
#define TYPE_ENUM_PROCEDURE   2
 
#define TYPE_ENUM_TRIGGER   3
 
#define TYPE_ENUM_PROXY   4
 
#define TL_OPTION_UPDATING   0x01
 
#define TL_OPTION_IGNORE_LEAVES   0x02
 
#define TL_OPTION_ALIAS   0x04
 
#define INDEX_HINT_MASK_JOIN   (1)
 
#define INDEX_HINT_MASK_GROUP   (1 << 1)
 
#define INDEX_HINT_MASK_ORDER   (1 << 2)
 
#define INDEX_HINT_MASK_ALL    (INDEX_HINT_MASK_JOIN | INDEX_HINT_MASK_GROUP | INDEX_HINT_MASK_ORDER)
 
#define BINLOG_DIRECT_ON
 
#define BINLOG_DIRECT_OFF
 
#define TRX_CACHE_EMPTY   0x33 /* unsafe when trx-cache is empty */
 
#define TRX_CACHE_NOT_EMPTY   0xCC /* unsafe when trx-cache is not empty */
 
#define IL_LT_REPEATABLE   0xAA /* unsafe when < ISO_REPEATABLE_READ */
 
#define IL_GTE_REPEATABLE   0x55 /* unsafe when >= ISO_REPEATABLE_READ */
 

Typedefs

using List_item = mem_root_deque< Item * >
 
using Group_list_ptrs = Mem_root_array< ORDER * >
 
typedef uchar index_clause_map
 
typedef Bounds_checked_array< Item * > Ref_item_array
 
typedef struct struct_replica_connection LEX_REPLICA_CONNECTION
 

Enumerations

enum  enum_keep_diagnostics {
  DA_KEEP_NOTHING = 0 , DA_KEEP_DIAGNOSTICS , DA_KEEP_COUNTS , DA_KEEP_PARSE_ERROR ,
  DA_KEEP_UNSPECIFIED
}
 
enum  enum_sp_suid_behaviour { SP_IS_DEFAULT_SUID = 0 , SP_IS_NOT_SUID , SP_IS_SUID }
 
enum  enum_sp_data_access {
  SP_DEFAULT_ACCESS = 0 , SP_CONTAINS_SQL , SP_NO_SQL , SP_READS_SQL_DATA ,
  SP_MODIFIES_SQL_DATA
}
 
enum class  enum_sp_type {
  enum_sp_type::FUNCTION = 1 , enum_sp_type::PROCEDURE , enum_sp_type::TRIGGER , enum_sp_type::EVENT ,
  enum_sp_type::INVALID_SP_TYPE
}
 enum_sp_type defines type codes of stored programs. More...
 
enum class  Acl_type { Acl_type::TABLE = 0 , Acl_type::FUNCTION = TYPE_ENUM_FUNCTION , Acl_type::PROCEDURE = TYPE_ENUM_PROCEDURE }
 
enum class  enum_view_create_mode { enum_view_create_mode::VIEW_CREATE_NEW , enum_view_create_mode::VIEW_ALTER , enum_view_create_mode::VIEW_CREATE_OR_REPLACE }
 
enum class  enum_alter_user_attribute { enum_alter_user_attribute::ALTER_USER_COMMENT_NOT_USED , enum_alter_user_attribute::ALTER_USER_COMMENT , enum_alter_user_attribute::ALTER_USER_ATTRIBUTE }
 
enum  sub_select_type { UNSPECIFIED_TYPE , GLOBAL_OPTIONS_TYPE , DERIVED_TABLE_TYPE }
 
enum class  enum_explain_type {
  enum_explain_type::EXPLAIN_NONE = 0 , enum_explain_type::EXPLAIN_PRIMARY , enum_explain_type::EXPLAIN_SIMPLE , enum_explain_type::EXPLAIN_DERIVED ,
  enum_explain_type::EXPLAIN_SUBQUERY , enum_explain_type::EXPLAIN_UNION , enum_explain_type::EXPLAIN_INTERSECT , enum_explain_type::EXPLAIN_EXCEPT ,
  enum_explain_type::EXPLAIN_UNION_RESULT , enum_explain_type::EXPLAIN_INTERSECT_RESULT , enum_explain_type::EXPLAIN_EXCEPT_RESULT , enum_explain_type::EXPLAIN_UNARY_RESULT ,
  enum_explain_type::EXPLAIN_MATERIALIZED , enum_explain_type::EXPLAIN_total
}
 Query_block type enum. More...
 
enum  enum_comment_state {
  NO_COMMENT , PRESERVE_COMMENT , DISCARD_COMMENT , NO_COMMENT ,
  PRESERVE_COMMENT , DISCARD_COMMENT
}
 The state of the lexical parser, when parsing comments. More...
 
enum  execute_only_in_secondary_reasons { SUPPORTED_IN_PRIMARY , CUBE , TABLESAMPLE }
 
enum  execute_only_in_hypergraph_reasons { SUPPORTED_IN_BOTH_OPTIMIZERS , QUALIFY_CLAUSE }
 

Functions

void binlog_unsafe_map_init ()
 
enum_sp_type to_sp_type (longlong val)
 
longlong to_longlong (enum_sp_type val)
 
uint to_uint (enum_sp_type val)
 
bool walk_join_list (mem_root_deque< Table_ref * > &list, std::function< bool(Table_ref *)> action)
 
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...
 
int my_sql_parser_lex (MY_SQL_PARSER_STYPE *, POS *, class THD *)
 yylex() function implementation for the main parser More...
 
void trim_whitespace (const CHARSET_INFO *cs, LEX_STRING *str)
 
bool is_lex_native_function (const LEX_STRING *name)
 Check if name is a sql function. More...
 
bool is_keyword (const char *name, size_t len)
 
bool db_is_default_db (const char *db, size_t db_len, const THD *thd)
 
bool check_select_for_locking_clause (THD *)
 
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...
 
bool is_invalid_string (const LEX_CSTRING &string_val, const CHARSET_INFO *charset_info)
 (End of group GROUP_PARSER) More...
 
bool is_invalid_string (const LEX_CSTRING &string_val, const CHARSET_INFO *charset_info, std::string &invalid_sub_str)
 Check if the given string is invalid using the system charset. More...
 
void assert_consistent_hidden_flags (const mem_root_deque< Item * > &fields, Item *item, bool hidden)
 In debug mode, verify that we're not adding an item twice to the fields list with inconsistent hidden flags. More...
 
bool walk_item (Item *item, Select_lex_visitor *visitor)
 
bool accept_for_order (SQL_I_List< ORDER > orders, Select_lex_visitor *visitor)
 
bool accept_table (Table_ref *t, Select_lex_visitor *visitor)
 
bool accept_for_join (mem_root_deque< Table_ref * > *tables, Select_lex_visitor *visitor)
 
Table_refnest_join (THD *thd, Query_block *select, Table_ref *embedding, mem_root_deque< Table_ref * > *jlist, size_t table_cnt, const char *legend)
 Plumbing for nest_last_join, q.v. More...
 
void get_select_options_str (ulonglong options, std::string *str)
 

Variables

const size_t INITIAL_LEX_PLUGIN_LIST_SIZE = 16
 
constexpr const int MAX_SELECT_NESTING {sizeof(nesting_map) * 8 - 1}
 
uint binlog_unsafe_map [256]
 
const LEX_CSTRING sp_data_access_name []
 
const char * index_hint_type_name []
 
const LEX_STRING null_lex_str
 LEX_STRING constant for null-string to be used in parser and other places. More...
 

Macro Definition Documentation

◆ BINLOG_DIRECT_OFF

#define BINLOG_DIRECT_OFF
Value:
0xF /* unsafe when \
--binlog-direct-non-trans-updates \
is OFF */

◆ BINLOG_DIRECT_ON

#define BINLOG_DIRECT_ON
Value:
0xF0 /* unsafe when \
--binlog-direct-non-trans-updates \
is ON */

◆ IL_GTE_REPEATABLE

#define IL_GTE_REPEATABLE   0x55 /* unsafe when >= ISO_REPEATABLE_READ */

◆ IL_LT_REPEATABLE

#define IL_LT_REPEATABLE   0xAA /* unsafe when < ISO_REPEATABLE_READ */

◆ TRX_CACHE_EMPTY

#define TRX_CACHE_EMPTY   0x33 /* unsafe when trx-cache is empty */

◆ TRX_CACHE_NOT_EMPTY

#define TRX_CACHE_NOT_EMPTY   0xCC /* unsafe when trx-cache is not empty */

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 
)

◆ assert_consistent_hidden_flags()

void assert_consistent_hidden_flags ( const mem_root_deque< Item * > &  fields,
Item item,
bool  hidden 
)
inline

In debug mode, verify that we're not adding an item twice to the fields list with inconsistent hidden flags.

Must be called before adding the item to fields.

◆ get_select_options_str()

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

◆ is_invalid_string() [1/2]

bool is_invalid_string ( const LEX_CSTRING string_val,
const CHARSET_INFO charset_info 
)
inline

(End of group GROUP_PARSER)

Check if the given string is invalid using the system charset.

Parameters
string_valReference to the string.
charset_infoPointer to charset info.
Returns
true if the string has an invalid encoding using the system charset else false.

◆ is_invalid_string() [2/2]

bool is_invalid_string ( const LEX_CSTRING string_val,
const CHARSET_INFO charset_info,
std::string &  invalid_sub_str 
)
inline

Check if the given string is invalid using the system charset.

Parameters
string_valReference to the string.
charset_infoPointer to charset info.
[out]invalid_sub_strIf string has an invalid encoding then invalid string in printable ASCII format is stored.
Returns
true if the string has an invalid encoding using the system charset else false.

◆ walk_item()

bool walk_item ( Item item,
Select_lex_visitor visitor 
)