MySQL  8.0.17
Source Code Documentation
Parser

Modules

 Instantiator functions
 The Instantiator functions are used to call constructors and operator new on classes that implement SQL functions, basically, even though they don't have to be functions.
 

Classes

class  Create_sp_func
 Function builder for stored functions. More...
 
class  Create_func
 Public function builder interface. More...
 
class  Create_qfunc
 Function builder for qualified functions. More...
 
class  Create_udf_func
 Function builder for User Defined Functions. More...
 
class  Table_ident
 
struct  LEX_MASTER_INFO
 Structure to hold parameters for CHANGE MASTER, START SLAVE, and STOP SLAVE. More...
 
struct  LEX_RESET_SLAVE
 
class  Index_hint
 
class  SELECT_LEX_UNIT
 This class represents a query expression (one query block or several query blocks combined with UNION). More...
 
class  SELECT_LEX
 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  Disable_semijoin_flattening
 Utility RAII class to save/modify/restore the semijoin_disallowed flag. More...
 
class  Secondary_engine_execution_context
 Base class for secondary engine execution context objects. More...
 
struct  struct_slave_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
 
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...
 
struct  st_lex_local
 

Macros

#define SQL_FN(F, N)   &Function_factory<Instantiator<F, N>>::s_singleton
 Shorthand macro to reference the singleton instance. More...
 
#define SQL_FACTORY(INSTANTIATOR)   &Function_factory<INSTANTIATOR>::s_singleton
 Shorthand macro to reference the singleton instance when there is a specialized intantiatior. More...
 
#define SQL_FN_V(F, MIN, MAX)   &Function_factory<Instantiator<F, MIN, MAX>>::s_singleton
 Use this macro if you want to instantiate the Item_func object like Item_func_xxx::Item_func_xxx(pos, args[0], ..., args[MAX]) More...
 
#define SQL_FN_V_THD(F, MIN, MAX)   &Function_factory<Instantiator_with_thd<F, MIN, MAX>>::s_singleton
 Use this macro if you want to instantiate the Item_func object like Item_func_xxx::Item_func_xxx(thd, pos, args[0], ..., args[MAX]) More...
 
#define SQL_FN_V_LIST(F, MIN, MAX)   &Function_factory<List_instantiator<F, MIN, MAX>>::s_singleton
 Use this macro if you want to instantiate the Item_func object like Item_func_xxx::Item_func_xxx(pos, item_list) More...
 
#define SQL_FN_LIST(F, N)   &Function_factory<List_instantiator<F, N>>::s_singleton
 Use this macro if you want to instantiate the Item_func object like Item_func_xxx::Item_func_xxx(pos, item_list) More...
 
#define SQL_FN_V_LIST_THD(F, MIN, MAX)   &Function_factory<List_instantiator_with_thd<F, MIN, MAX>>::s_singleton
 Use this macro if you want to instantiate the Item_func object like Item_func_xxx::Item_func_xxx(thd, pos, item_list) More...
 
#define SQL_FN_ODD(F, MIN, MAX)
 Just like SQL_FN_V_THD, but enforces a check that the argument count is odd. More...
 
#define SQL_FN_EVEN(F, MIN, MAX)
 Just like SQL_FN_V_THD, but enforces a check that the argument count is even. More...
 
#define SQL_FN_INTERNAL(F, N)   &Internal_function_factory<Instantiator<F, N>>::s_singleton
 Like SQL_FN, but for functions that may only be referenced from system views. More...
 
#define SQL_FN_INTERNAL_V(F, MIN, MAX)   &Internal_function_factory<Instantiator<F, MIN, MAX>>::s_singleton
 Just like SQL_FN_INTERNAL, but enforces a check that the argument count is even. More...
 
#define SQL_FN_LIST_INTERNAL(F, N)   &Internal_function_factory<List_instantiator<F, N>>::s_singleton
 Like SQL_FN_LIST, but for functions that may only be referenced from system views. More...
 
#define SQL_FN_LIST_INTERNAL_V(F, MIN, MAX)   &Internal_function_factory<List_instantiator<F, MIN, MAX>>::s_singleton
 Like SQL_FN_LIST, but enforces a check that the argument count is within the range specified. More...
 
#define TYPE_ENUM_FUNCTION   1
 
#define TYPE_ENUM_PROCEDURE   2
 
#define TYPE_ENUM_TRIGGER   3
 
#define TYPE_ENUM_PROXY   4
 
#define TL_OPTION_UPDATING   1
 
#define TL_OPTION_FORCE_INDEX   2
 
#define TL_OPTION_IGNORE_LEAVES   4
 
#define TL_OPTION_ALIAS   8
 
#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 CF_CHANGES_DATA   (1U << 0)
 
#define CF_STATUS_COMMAND   (1U << 2)
 
#define CF_SHOW_TABLE_COMMAND   (1U << 3)
 
#define CF_WRITE_LOGS_COMMAND   (1U << 4)
 
#define CF_REEXECUTION_FRAGILE   (1U << 5)
 Must be set for SQL statements that may contain Item expressions and/or use joins and tables. More...
 
#define CF_IMPLICIT_COMMIT_BEGIN   (1U << 6)
 Implicitly commit before the SQL statement is executed. More...
 
#define CF_IMPLICIT_COMMIT_END   (1U << 7)
 Implicitly commit after the SQL statement. More...
 
#define CF_AUTO_COMMIT_TRANS   (CF_IMPLICIT_COMMIT_BEGIN | CF_IMPLICIT_COMMIT_END)
 CF_IMPLICIT_COMMIT_BEGIN and CF_IMPLICIT_COMMIT_END are used to ensure that the active transaction is implicitly committed before and after every DDL statement and any statement that modifies our currently non-transactional system tables. More...
 
#define CF_DIAGNOSTIC_STMT   (1U << 8)
 Diagnostic statement. More...
 
#define CF_CAN_GENERATE_ROW_EVENTS   (1U << 9)
 Identifies statements that may generate row events and that may end up in the binary log. More...
 
#define CF_PREOPEN_TMP_TABLES   (1U << 10)
 Identifies statements which may deal with temporary tables and for which temporary tables should be pre-opened to simplify privilege checks. More...
 
#define CF_HA_CLOSE   (1U << 11)
 Identifies statements for which open handlers should be closed in the beginning of the statement. More...
 
#define CF_CAN_BE_EXPLAINED   (1U << 12)
 Identifies statements that can be explained with EXPLAIN. More...
 
#define CF_OPTIMIZER_TRACE   (1U << 14)
 Identifies statements which may generate an optimizer trace. More...
 
#define CF_DISALLOW_IN_RO_TRANS   (1U << 15)
 Identifies statements that should always be disallowed in read only transactions. More...
 
#define CF_ALLOW_PROTOCOL_PLUGIN   (1U << 16)
 Identifies statements and commands that can be used with Protocol Plugin. More...
 
#define CF_NEEDS_AUTOCOMMIT_OFF   (1U << 17)
 Identifies statements (typically DDL) which needs auto-commit mode temporarily turned off. More...
 
#define CF_HAS_RESULT_SET   (1U << 18)
 Identifies statements which can return rows of data columns (SELECT, SHOW ...) More...
 
#define CF_POTENTIAL_ATOMIC_DDL   (1U << 19)
 Identifies DDL statements which can be atomic. More...
 
#define CF_REQUIRE_ACL_CACHE   (1U << 20)
 Statement is depending on the ACL cache, which can be disabled by the –skip-grant-tables server option. More...
 
#define CF_SKIP_QUERY_ID   (1U << 0)
 Skip the increase of the global query id counter. More...
 
#define CF_SKIP_QUESTIONS   (1U << 1)
 Skip the increase of the number of statements that clients have sent to the server. More...
 

Typedefs

using Native_functions_hash = std::unordered_map< std::string, Create_func * >
 
typedef List< ItemList_item
 
typedef Mem_root_array< ORDER * > Group_list_ptrs
 
typedef uchar index_clause_map
 
typedef Bounds_checked_array< Item * > Ref_item_array
 
typedef struct struct_slave_connection LEX_SLAVE_CONNECTION
 

Enumerations

enum  Cast_target : unsigned char {
  ITEM_CAST_SIGNED_INT, ITEM_CAST_UNSIGNED_INT, ITEM_CAST_DATE, ITEM_CAST_TIME,
  ITEM_CAST_DATETIME, ITEM_CAST_CHAR, ITEM_CAST_DECIMAL, ITEM_CAST_JSON,
  ITEM_CAST_FLOAT, ITEM_CAST_DOUBLE
}
 
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  enum_sp_type { enum_sp_type::FUNCTION = 1, enum_sp_type::PROCEDURE, enum_sp_type::TRIGGER, enum_sp_type::EVENT }
 enum_sp_type defines type codes of stored programs. More...
 
enum  Acl_type { Acl_type::TABLE = 0, Acl_type::FUNCTION = TYPE_ENUM_FUNCTION, Acl_type::PROCEDURE = TYPE_ENUM_PROCEDURE }
 
enum  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  sub_select_type {
  UNSPECIFIED_TYPE, UNION_TYPE, INTERSECT_TYPE, EXCEPT_TYPE,
  GLOBAL_OPTIONS_TYPE, DERIVED_TABLE_TYPE, OLAP_TYPE
}
 
enum  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_UNION_RESULT, enum_explain_type::EXPLAIN_MATERIALIZED,
  enum_explain_type::EXPLAIN_total
}
 SELECT_LEX type enum. More...
 
enum  enum_comment_state { NO_COMMENT, PRESERVE_COMMENT, DISCARD_COMMENT }
 The state of the lexical parser, when parsing comments. More...
 

Functions

uint arglist_length (const PT_item_list *args)
 
bool check_argcount_bounds (THD *, LEX_STRING function_name, PT_item_list *item_list, uint min_argcount, uint max_argcount)
 
bool item_create_init ()
 Load the hash table for native functions. More...
 
void item_create_cleanup ()
 Empty the hash table for native functions. More...
 
Create_funcfind_native_function_builder (const LEX_STRING &name)
 Find the native function builder associated with a given function name. More...
 
Create_qfuncfind_qualified_function_builder (THD *thd)
 Find the function builder for qualified functions. More...
 
Itemcreate_func_cast (THD *thd, const POS &pos, Item *a, Cast_target cast_target, const CHARSET_INFO *cs)
 
Itemcreate_func_cast (THD *thd, const POS &pos, Item *a, const Cast_type *type, bool as_array=false)
 Builder for cast expressions. More...
 
Itemcreate_temporal_literal (THD *thd, const char *str, size_t length, const CHARSET_INFO *cs, enum_field_types type, bool send_error)
 Builder for datetime literals: TIME'00:00:00', DATE'2001-01-01', TIMESTAMP'2001-01-01 00:00:00'. More...
 
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 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...
 
int MYSQLlex (union YYSTYPE *, struct YYLTYPE *, 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...
 
int test_if_data_home_dir (const char *dir)
 
bool stmt_causes_implicit_commit (const THD *thd, uint mask)
 Returns whether the command in thd->lex->sql_command should cause an implicit commit. More...
 
void turn_parser_debug_on ()
 
bool parse_sql (THD *thd, Parser_state *parser_state, Object_creation_ctx *creation_ctx)
 Transform an SQL statement into an AST that is ready for resolving, using the supplied parser state and object creation context. More...
 
void free_items (Item *item)
 
void cleanup_items (Item *item)
 This works because items are allocated with (*THR_MALLOC)->Alloc(). More...
 
Comp_creatorcomp_eq_creator (bool invert)
 
Comp_creatorcomp_equal_creator (bool invert)
 
Comp_creatorcomp_ge_creator (bool invert)
 
Comp_creatorcomp_gt_creator (bool invert)
 
Comp_creatorcomp_le_creator (bool invert)
 
Comp_creatorcomp_lt_creator (bool invert)
 
Comp_creatorcomp_ne_creator (bool invert)
 
int prepare_schema_table (THD *thd, LEX *lex, Table_ident *table_ident, enum enum_schema_tables schema_table_idx)
 Create a TABLE_LIST object for an INFORMATION_SCHEMA table. More...
 
void get_default_definer (THD *thd, LEX_USER *definer)
 Set the specified definer to the default value, which is the current user in the thread. More...
 
LEX_USERcreate_default_definer (THD *thd)
 Create default definer for the specified THD. More...
 
LEX_USERget_current_user (THD *thd, LEX_USER *user)
 Retuns information about user or current user. More...
 
bool check_string_char_length (const LEX_CSTRING &str, const char *err_msg, size_t max_char_length, const CHARSET_INFO *cs, bool no_error)
 
bool merge_charset_and_collation (const CHARSET_INFO *charset, const CHARSET_INFO *collation, const CHARSET_INFO **to)
 (end of group Runtime_Environment) More...
 
bool merge_sp_var_charset_and_collation (const CHARSET_INFO *charset, const CHARSET_INFO *collation, const CHARSET_INFO **to)
 
bool check_host_name (const LEX_CSTRING &str)
 Check that host name string is valid. More...
 
bool mysql_test_parse_for_slave (THD *thd)
 Usable by the replication SQL thread only: just parse a query to know if it can be ignored because of replicate-*-table rules. More...
 
bool is_update_query (enum enum_sql_command command)
 
bool is_explainable_query (enum enum_sql_command command)
 
bool is_log_table_write_query (enum enum_sql_command command)
 Check if a sql command is allowed to write to log tables. More...
 
bool alloc_query (THD *thd, const char *packet, size_t packet_length)
 Read query from packet and store in thd->query. More...
 
void mysql_parse (THD *thd, Parser_state *parser_state)
 Parse a query. More...
 
void mysql_reset_thd_for_next_command (THD *thd)
 Reset the part of THD responsible for the state of command processing. More...
 
bool create_select_for_variable (Parse_context *pc, const char *var_name)
 Create a select to return the same output as 'SELECT @var_name'. More...
 
void create_table_set_open_action_and_adjust_tables (LEX *lex)
 Set proper open mode and table type for element representing target table of CREATE TABLE statement, also adjust statement table list if necessary. More...
 
int mysql_execute_command (THD *thd, bool first_level=false)
 Execute command saved in thd and lex->sql_command. More...
 
bool do_command (THD *thd)
 Read one command from connection and execute it (query or simple command). More...
 
bool dispatch_command (THD *thd, const COM_DATA *com_data, enum enum_server_command command)
 Perform one connection-level (COM_XXXX) command. More...
 
bool prepare_index_and_data_dir_path (THD *thd, const char **data_file_name, const char **index_file_name, const char *table_name)
 prepares the index and data directory path. More...
 
int append_file_to_dir (THD *thd, const char **filename_ptr, const char *table_name)
 If pointer is not a null pointer, append filename to it. More...
 
void execute_init_command (THD *thd, LEX_STRING *init_command, mysql_rwlock_t *var_lock)
 
void add_to_list (SQL_I_List< ORDER > &list, ORDER *order)
 save order by and tables in own lists. More...
 
void add_join_on (TABLE_LIST *b, Item *expr)
 Add an ON condition to the second operand of a JOIN ... More...
 
bool push_new_name_resolution_context (Parse_context *pc, TABLE_LIST *left_op, TABLE_LIST *right_op)
 Push a new name resolution context for a JOIN ... More...
 
void init_sql_command_flags (void)
 
const CHARSET_INFOget_bin_collation (const CHARSET_INFO *cs)
 
void killall_non_super_threads (THD *thd)
 
bool shutdown (THD *thd, enum mysql_enum_shutdown_level level)
 Shutdown the mysqld server. More...
 
bool show_precheck (THD *thd, LEX *lex, bool lock)
 Do special checking for SHOW statements. More...
 
bool is_supported_parser_charset (const CHARSET_INFO *cs)
 
bool sqlcom_can_generate_row_events (enum enum_sql_command command)
 
bool all_tables_not_ok (THD *thd, TABLE_LIST *tables)
 Returns true if all tables should be ignored. More...
 
bool some_non_temp_table_to_be_updated (THD *thd, TABLE_LIST *tables)
 
bool execute_show (THD *thd, TABLE_LIST *all_tables)
 
bool set_default_charset (HA_CREATE_INFO *create_info, const CHARSET_INFO *value)
 
bool set_default_collation (HA_CREATE_INFO *create_info, const CHARSET_INFO *value)
 
virtual ItemCreate_qfunc::create_func (THD *thd, LEX_STRING name, PT_item_list *item_list)
 The builder create method, for unqualified functions. More...
 
virtual ItemCreate_udf_func::create_func (THD *thd, LEX_STRING name, PT_item_list *item_list)
 The builder create method. More...
 
ItemCreate_udf_func::create (THD *thd, udf_func *fct, PT_item_list *item_list)
 The builder create method, for User Defined Functions. More...
 
virtual ItemCreate_sp_func::create (THD *thd, LEX_STRING db, LEX_STRING name, bool use_explicit_name, PT_item_list *item_list)
 The builder create method, for qualified functions. More...
 
bool SELECT_LEX_UNIT::is_union () const
 

Variables

static const std::pair< const char *, Create_func * > func_array []
 MySQL native functions. More...
 
static const Native_functions_hashnative_functions_hash
 
CHARSET_INFO my_charset_utf8mb4_0900_bin
 
const size_t INITIAL_LEX_PLUGIN_LIST_SIZE = 16
 
uint binlog_unsafe_map [256]
 
const LEX_CSTRING sp_data_access_name []
 
LEX_CSTRING EMPTY_CSTR
 
LEX_CSTRING NULL_CSTR
 
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...
 
const LEX_STRING empty_lex_str
 
sys_vartrg_new_row_fake_var
 
uint sql_command_flags []
 Mark all commands that somehow changes a table. More...
 
const LEX_STRING command_name []
 
static Create_udf_func Create_udf_func::s_singleton
 Singleton. More...
 
static Create_sp_func Create_sp_func::s_singleton
 

Detailed Description

Macro Definition Documentation

◆ CF_ALLOW_PROTOCOL_PLUGIN

#define CF_ALLOW_PROTOCOL_PLUGIN   (1U << 16)

Identifies statements and commands that can be used with Protocol Plugin.

◆ CF_AUTO_COMMIT_TRANS

#define CF_AUTO_COMMIT_TRANS   (CF_IMPLICIT_COMMIT_BEGIN | CF_IMPLICIT_COMMIT_END)

CF_IMPLICIT_COMMIT_BEGIN and CF_IMPLICIT_COMMIT_END are used to ensure that the active transaction is implicitly committed before and after every DDL statement and any statement that modifies our currently non-transactional system tables.

◆ CF_CAN_BE_EXPLAINED

#define CF_CAN_BE_EXPLAINED   (1U << 12)

Identifies statements that can be explained with EXPLAIN.

◆ CF_CAN_GENERATE_ROW_EVENTS

#define CF_CAN_GENERATE_ROW_EVENTS   (1U << 9)

Identifies statements that may generate row events and that may end up in the binary log.

◆ CF_CHANGES_DATA

#define CF_CHANGES_DATA   (1U << 0)

◆ CF_DIAGNOSTIC_STMT

#define CF_DIAGNOSTIC_STMT   (1U << 8)

Diagnostic statement.

Diagnostic statements:

  • SHOW WARNING
  • SHOW ERROR
  • GET DIAGNOSTICS (WL#2111) do not modify the Diagnostics Area during execution.

◆ CF_DISALLOW_IN_RO_TRANS

#define CF_DISALLOW_IN_RO_TRANS   (1U << 15)

Identifies statements that should always be disallowed in read only transactions.

◆ CF_HA_CLOSE

#define CF_HA_CLOSE   (1U << 11)

Identifies statements for which open handlers should be closed in the beginning of the statement.

◆ CF_HAS_RESULT_SET

#define CF_HAS_RESULT_SET   (1U << 18)

Identifies statements which can return rows of data columns (SELECT, SHOW ...)

◆ CF_IMPLICIT_COMMIT_BEGIN

#define CF_IMPLICIT_COMMIT_BEGIN   (1U << 6)

Implicitly commit before the SQL statement is executed.

Statements marked with this flag will cause any active transaction to end (commit) before proceeding with the command execution.

This flag should be set for statements that probably can't be rolled back or that do not expect any previously metadata locked tables.

◆ CF_IMPLICIT_COMMIT_END

#define CF_IMPLICIT_COMMIT_END   (1U << 7)

Implicitly commit after the SQL statement.

Statements marked with this flag are automatically committed at the end of the statement.

This flag should be set for statements that will implicitly open and take metadata locks on system tables that should not be carried for the whole duration of a active transaction.

◆ CF_NEEDS_AUTOCOMMIT_OFF

#define CF_NEEDS_AUTOCOMMIT_OFF   (1U << 17)

Identifies statements (typically DDL) which needs auto-commit mode temporarily turned off.

Note
This is necessary to prevent InnoDB from automatically committing InnoDB transaction each time data-dictionary tables are closed after being updated.
This is also necessary for ACL DDL, so the code which saves GTID state or slave state in the system tables at the commit time works correctly. This code does statement commit on low-level (see System_table_access:: close_table()) and thus can pre-maturely commit DDL if @autocommit=1.

◆ CF_OPTIMIZER_TRACE

#define CF_OPTIMIZER_TRACE   (1U << 14)

Identifies statements which may generate an optimizer trace.

◆ CF_POTENTIAL_ATOMIC_DDL

#define CF_POTENTIAL_ATOMIC_DDL   (1U << 19)

Identifies DDL statements which can be atomic.

Having the bit ON does not yet define an atomic. The property is used both on the master and slave. On the master atomicity infers the binlog and gtid_executed system table. On the slave it more involves the slave info table.

Note
At the momemnt of declaration the covered DDL subset coincides with the of CF_NEEDS_AUTOCOMMIT_OFF.

◆ CF_PREOPEN_TMP_TABLES

#define CF_PREOPEN_TMP_TABLES   (1U << 10)

Identifies statements which may deal with temporary tables and for which temporary tables should be pre-opened to simplify privilege checks.

◆ CF_REEXECUTION_FRAGILE

#define CF_REEXECUTION_FRAGILE   (1U << 5)

Must be set for SQL statements that may contain Item expressions and/or use joins and tables.

Indicates that the parse tree of such statement may contain rule-based optimizations that depend on metadata (i.e. number of columns in a table), and consequently that the statement must be re-prepared whenever referenced metadata changes. Must not be set for statements that themselves change metadata, e.g. RENAME, ALTER and other DDL, since otherwise will trigger constant reprepare. Consequently, complex item expressions and joins are currently prohibited in these statements.

◆ CF_REQUIRE_ACL_CACHE

#define CF_REQUIRE_ACL_CACHE   (1U << 20)

Statement is depending on the ACL cache, which can be disabled by the –skip-grant-tables server option.

◆ CF_SHOW_TABLE_COMMAND

#define CF_SHOW_TABLE_COMMAND   (1U << 3)

◆ CF_SKIP_QUERY_ID

#define CF_SKIP_QUERY_ID   (1U << 0)

Skip the increase of the global query id counter.

Commonly set for commands that are stateless (won't cause any change on the server internal states). This is made obsolete as query id is incremented for ping and statistics commands as well because of race condition (Bug#58785).

◆ CF_SKIP_QUESTIONS

#define CF_SKIP_QUESTIONS   (1U << 1)

Skip the increase of the number of statements that clients have sent to the server.

Commonly used for commands that will cause a statement to be executed but the statement might have not been sent by the user (ie: stored procedure).

◆ CF_STATUS_COMMAND

#define CF_STATUS_COMMAND   (1U << 2)

◆ CF_WRITE_LOGS_COMMAND

#define CF_WRITE_LOGS_COMMAND   (1U << 4)

◆ INDEX_HINT_MASK_ALL

#define INDEX_HINT_MASK_ALL   (INDEX_HINT_MASK_JOIN | INDEX_HINT_MASK_GROUP | INDEX_HINT_MASK_ORDER)

◆ INDEX_HINT_MASK_GROUP

#define INDEX_HINT_MASK_GROUP   (1 << 1)

◆ INDEX_HINT_MASK_JOIN

#define INDEX_HINT_MASK_JOIN   (1)

◆ INDEX_HINT_MASK_ORDER

#define INDEX_HINT_MASK_ORDER   (1 << 2)

◆ SQL_FACTORY

#define SQL_FACTORY (   INSTANTIATOR)    &Function_factory<INSTANTIATOR>::s_singleton

Shorthand macro to reference the singleton instance when there is a specialized intantiatior.

Parameters
INSTANTIATORThe instantiator class.

◆ SQL_FN

#define SQL_FN (   F,
 
)    &Function_factory<Instantiator<F, N>>::s_singleton

Shorthand macro to reference the singleton instance.

This also instantiates the Function_factory and Instantiator templates.

Parameters
FThe Item_func that the factory should make.
NNumber of arguments that the function accepts.

◆ SQL_FN_EVEN

#define SQL_FN_EVEN (   F,
  MIN,
  MAX 
)
Value:
&Even_argcount_function_factory< \
List_instantiator_with_thd<F, MIN, MAX>>::s_singleton

Just like SQL_FN_V_THD, but enforces a check that the argument count is even.

◆ SQL_FN_INTERNAL

#define SQL_FN_INTERNAL (   F,
 
)    &Internal_function_factory<Instantiator<F, N>>::s_singleton

Like SQL_FN, but for functions that may only be referenced from system views.

Parameters
FThe Item_func that the factory should make.
NNumber of arguments that the function accepts.

◆ SQL_FN_INTERNAL_V

#define SQL_FN_INTERNAL_V (   F,
  MIN,
  MAX 
)    &Internal_function_factory<Instantiator<F, MIN, MAX>>::s_singleton

Just like SQL_FN_INTERNAL, but enforces a check that the argument count is even.

Parameters
FThe Item_func that the factory should make.
MINNumber of arguments that the function accepts.
MAXNumber of arguments that the function accepts.

◆ SQL_FN_LIST

#define SQL_FN_LIST (   F,
 
)    &Function_factory<List_instantiator<F, N>>::s_singleton

Use this macro if you want to instantiate the Item_func object like Item_func_xxx::Item_func_xxx(pos, item_list)

This also instantiates the Function_factory and Instantiator templates.

Parameters
FThe Item_func that the factory should make.
NNumber of arguments that the function accepts.

◆ SQL_FN_LIST_INTERNAL

#define SQL_FN_LIST_INTERNAL (   F,
 
)    &Internal_function_factory<List_instantiator<F, N>>::s_singleton

Like SQL_FN_LIST, but for functions that may only be referenced from system views.

Parameters
FThe Item_func that the factory should make.
NNumber of arguments that the function accepts.

◆ SQL_FN_LIST_INTERNAL_V

#define SQL_FN_LIST_INTERNAL_V (   F,
  MIN,
  MAX 
)    &Internal_function_factory<List_instantiator<F, MIN, MAX>>::s_singleton

Like SQL_FN_LIST, but enforces a check that the argument count is within the range specified.

Parameters
FThe Item_func that the factory should make.
MINNumber of arguments that the function accepts.
MAXNumber of arguments that the function accepts.

◆ SQL_FN_ODD

#define SQL_FN_ODD (   F,
  MIN,
  MAX 
)
Value:
&Odd_argcount_function_factory< \
List_instantiator_with_thd<F, MIN, MAX>>::s_singleton

Just like SQL_FN_V_THD, but enforces a check that the argument count is odd.

◆ SQL_FN_V

#define SQL_FN_V (   F,
  MIN,
  MAX 
)    &Function_factory<Instantiator<F, MIN, MAX>>::s_singleton

Use this macro if you want to instantiate the Item_func object like Item_func_xxx::Item_func_xxx(pos, args[0], ..., args[MAX])

This also instantiates the Function_factory and Instantiator templates.

Parameters
FThe Item_func that the factory should make.
MINNumber of arguments that the function accepts.
MAXNumber of arguments that the function accepts.

◆ SQL_FN_V_LIST

#define SQL_FN_V_LIST (   F,
  MIN,
  MAX 
)    &Function_factory<List_instantiator<F, MIN, MAX>>::s_singleton

Use this macro if you want to instantiate the Item_func object like Item_func_xxx::Item_func_xxx(pos, item_list)

This also instantiates the Function_factory and Instantiator templates.

Parameters
FThe Item_func that the factory should make.
MINNumber of arguments that the function accepts.
MAXNumber of arguments that the function accepts.

◆ SQL_FN_V_LIST_THD

#define SQL_FN_V_LIST_THD (   F,
  MIN,
  MAX 
)    &Function_factory<List_instantiator_with_thd<F, MIN, MAX>>::s_singleton

Use this macro if you want to instantiate the Item_func object like Item_func_xxx::Item_func_xxx(thd, pos, item_list)

This also instantiates the Function_factory and Instantiator templates.

Parameters
FThe Item_func that the factory should make.
MINNumber of arguments that the function accepts.
MAXNumber of arguments that the function accepts.

◆ SQL_FN_V_THD

#define SQL_FN_V_THD (   F,
  MIN,
  MAX 
)    &Function_factory<Instantiator_with_thd<F, MIN, MAX>>::s_singleton

Use this macro if you want to instantiate the Item_func object like Item_func_xxx::Item_func_xxx(thd, pos, args[0], ..., args[MAX])

This also instantiates the Function_factory and Instantiator templates.

Parameters
FThe Item_func that the factory should make.
MINNumber of arguments that the function accepts.
MAXNumber of arguments that the function accepts.

◆ TL_OPTION_ALIAS

#define TL_OPTION_ALIAS   8

◆ TL_OPTION_FORCE_INDEX

#define TL_OPTION_FORCE_INDEX   2

◆ TL_OPTION_IGNORE_LEAVES

#define TL_OPTION_IGNORE_LEAVES   4

◆ TL_OPTION_UPDATING

#define TL_OPTION_UPDATING   1

◆ TYPE_ENUM_FUNCTION

#define TYPE_ENUM_FUNCTION   1

◆ TYPE_ENUM_PROCEDURE

#define TYPE_ENUM_PROCEDURE   2

◆ TYPE_ENUM_PROXY

#define TYPE_ENUM_PROXY   4

◆ TYPE_ENUM_TRIGGER

#define TYPE_ENUM_TRIGGER   3

Typedef Documentation

◆ Group_list_ptrs

◆ index_clause_map

◆ LEX_SLAVE_CONNECTION

◆ List_item

typedef List<Item> List_item

◆ Native_functions_hash

using Native_functions_hash = std::unordered_map<std::string, Create_func *>

◆ Ref_item_array

Enumeration Type Documentation

◆ Acl_type

enum Acl_type
strong
Enumerator
TABLE 
FUNCTION 
PROCEDURE 

◆ Cast_target

enum Cast_target : unsigned char
Enumerator
ITEM_CAST_SIGNED_INT 
ITEM_CAST_UNSIGNED_INT 
ITEM_CAST_DATE 
ITEM_CAST_TIME 
ITEM_CAST_DATETIME 
ITEM_CAST_CHAR 
ITEM_CAST_DECIMAL 
ITEM_CAST_JSON 
ITEM_CAST_FLOAT 
ITEM_CAST_DOUBLE 

◆ enum_comment_state

The state of the lexical parser, when parsing comments.

Enumerator
NO_COMMENT 

Not parsing comments.

PRESERVE_COMMENT 

Parsing comments that need to be preserved.

(Copy '/' '*' and '*' '/' sequences to the preprocessed buffer.) Typically, these are user comments '/' '*' ... '*' '/'.

DISCARD_COMMENT 

Parsing comments that need to be discarded.

(Don't copy '/' '*' '!' and '*' '/' sequences to the preprocessed buffer.) Typically, these are special comments '/' '*' '!' ... '*' '/', or '/' '*' '!' 'M' 'M' 'm' 'm' 'm' ... '*' '/', where the comment markers should not be expanded.

◆ enum_explain_type

enum enum_explain_type
strong

SELECT_LEX type enum.

Enumerator
EXPLAIN_NONE 
EXPLAIN_PRIMARY 
EXPLAIN_SIMPLE 
EXPLAIN_DERIVED 
EXPLAIN_SUBQUERY 
EXPLAIN_UNION 
EXPLAIN_UNION_RESULT 
EXPLAIN_MATERIALIZED 
EXPLAIN_total 

fake type, total number of all valid types

◆ enum_keep_diagnostics

Enumerator
DA_KEEP_NOTHING 

keep nothing

DA_KEEP_DIAGNOSTICS 

keep the diagnostics area

DA_KEEP_COUNTS 

keep @warning_count / @error_count

DA_KEEP_PARSE_ERROR 

keep diagnostics area after parse error

DA_KEEP_UNSPECIFIED 

keep semantics is unspecified

◆ enum_sp_data_access

Enumerator
SP_DEFAULT_ACCESS 
SP_CONTAINS_SQL 
SP_NO_SQL 
SP_READS_SQL_DATA 
SP_MODIFIES_SQL_DATA 

◆ enum_sp_suid_behaviour

Enumerator
SP_IS_DEFAULT_SUID 
SP_IS_NOT_SUID 
SP_IS_SUID 

◆ enum_sp_type

enum enum_sp_type
strong

enum_sp_type defines type codes of stored programs.

Note
these codes are used when dealing with the mysql.routines system table, so they must not be changed.
the following macros were used previously for the same purpose. Now they are used for ACL only.
Enumerator
FUNCTION 
PROCEDURE 
TRIGGER 
EVENT 

◆ enum_view_create_mode

enum enum_view_create_mode
strong
Enumerator
VIEW_CREATE_NEW 
VIEW_ALTER 
VIEW_CREATE_OR_REPLACE 

◆ sub_select_type

Enumerator
UNSPECIFIED_TYPE 
UNION_TYPE 
INTERSECT_TYPE 
EXCEPT_TYPE 
GLOBAL_OPTIONS_TYPE 
DERIVED_TABLE_TYPE 
OLAP_TYPE 

Function Documentation

◆ add_join_on()

void add_join_on ( TABLE_LIST b,
Item expr 
)

Add an ON condition to the second operand of a JOIN ...

ON.

Add an ON condition to the right operand of a JOIN ... ON clause.

Parameters
bthe second operand of a JOIN ... ON
exprthe condition to be added to the ON clause

◆ add_to_list()

void add_to_list ( SQL_I_List< ORDER > &  list,
ORDER order 
)

save order by and tables in own lists.

◆ all_tables_not_ok()

bool all_tables_not_ok ( THD thd,
TABLE_LIST tables 
)

Returns true if all tables should be ignored.

◆ alloc_query()

bool alloc_query ( THD thd,
const char *  packet,
size_t  packet_length 
)

Read query from packet and store in thd->query.

Used in COM_QUERY and COM_STMT_PREPARE.

Sets the following THD variables:

  • query
  • query_length
Return values
falseok
trueerror; In this case thd->fatal_error is set

◆ append_file_to_dir()

int append_file_to_dir ( THD thd,
const char **  filename_ptr,
const char *  table_name 
)

If pointer is not a null pointer, append filename to it.

◆ arglist_length()

uint arglist_length ( const PT_item_list args)

◆ binlog_unsafe_map_init()

void binlog_unsafe_map_init ( )

◆ check_argcount_bounds()

bool check_argcount_bounds ( THD ,
LEX_STRING  function_name,
PT_item_list item_list,
uint  min_argcount,
uint  max_argcount 
)

◆ check_host_name()

bool check_host_name ( const LEX_CSTRING str)

Check that host name string is valid.

Parameters
[in]strstring to be checked
Returns
Operation status
Return values
falsehost name is ok
truehost name string is longer than max_length or has invalid symbols

◆ check_select_for_locking_clause()

bool check_select_for_locking_clause ( THD )

◆ check_string_char_length()

bool check_string_char_length ( const LEX_CSTRING str,
const char *  err_msg,
size_t  max_char_length,
const CHARSET_INFO cs,
bool  no_error 
)

◆ cleanup_items()

void cleanup_items ( Item item)

This works because items are allocated with (*THR_MALLOC)->Alloc().

Note
The function also handles null pointers (empty list).

◆ comp_eq_creator()

Comp_creator* comp_eq_creator ( bool  invert)

◆ comp_equal_creator()

Comp_creator* comp_equal_creator ( bool  invert)

◆ comp_ge_creator()

Comp_creator* comp_ge_creator ( bool  invert)

◆ comp_gt_creator()

Comp_creator* comp_gt_creator ( bool  invert)

◆ comp_le_creator()

Comp_creator* comp_le_creator ( bool  invert)

◆ comp_lt_creator()

Comp_creator* comp_lt_creator ( bool  invert)

◆ comp_ne_creator()

Comp_creator* comp_ne_creator ( bool  invert)

◆ create() [1/2]

Item * Create_udf_func::create ( THD thd,
udf_func fct,
PT_item_list item_list 
)

The builder create method, for User Defined Functions.

Parameters
thdThe current thread
fctThe User Defined Function metadata
item_listThe list of arguments to the function, can be NULL
Returns
An item representing the parsed function call

◆ create() [2/2]

Item * Create_sp_func::create ( THD thd,
LEX_STRING  db,
LEX_STRING  name,
bool  use_explicit_name,
PT_item_list item_list 
)
virtual

The builder create method, for qualified functions.

Parameters
thdThe current thread
dbThe database name or NULL_STR to use the default db name
nameThe function name
use_explicit_nameShould the function be represented as 'db.name'?
item_listThe list of arguments to the function, can be NULL
Returns
An item representing the parsed function call

Implements Create_qfunc.

◆ create_default_definer()

LEX_USER* create_default_definer ( THD thd)

Create default definer for the specified THD.

Parameters
[in]thdthread handler
Returns
  • On success, return a valid pointer to the created and initialized LEX_USER, which contains definer information.
  • On error, return 0.

◆ create_func() [1/2]

Item * Create_qfunc::create_func ( THD thd,
LEX_STRING  name,
PT_item_list item_list 
)
virtual

The builder create method, for unqualified functions.

This builder will use the current database for the database name.

Parameters
thdThe current thread
nameThe function name
item_listThe list of arguments to the function, can be NULL
Returns
An item representing the parsed function call

Implements Create_func.

◆ create_func() [2/2]

Item * Create_udf_func::create_func ( THD thd,
LEX_STRING  name,
PT_item_list item_list 
)
virtual

The builder create method.

Given the function name and list or arguments, this method creates an Item that represents the function call. In case or errors, a NULL item is returned, and an error is reported. Note that the thd object may be modified by the builder. In particular, the following members/methods can be set/called, depending on the function called and the function possible side effects.

  • thd->lex->binlog_row_based_if_mixed
  • thd->lex->current_context()
  • thd->lex->safe_to_cache_query
  • thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT)
  • thd->lex->uncacheable(UNCACHEABLE_RAND)
  • thd->lex->add_time_zone_tables_to_query_tables(thd)
Parameters
thdThe current thread
nameThe function name
item_listThe list of arguments to the function, can be NULL
Returns
An item representing the parsed function call, or NULL

Implements Create_func.

◆ create_func_cast() [1/2]

Item * create_func_cast ( THD thd,
const POS pos,
Item a,
Cast_target  cast_target,
const CHARSET_INFO cs 
)

◆ create_func_cast() [2/2]

Item * create_func_cast ( THD thd,
const POS pos,
Item a,
const Cast_type type,
bool  as_array = false 
)

Builder for cast expressions.

Parameters
thdThe current thread
posLocation of casting expression
aThe item to cast
typethe type casted into
as_arrayCast to array

◆ create_select_for_variable()

bool create_select_for_variable ( Parse_context pc,
const char *  var_name 
)

Create a select to return the same output as 'SELECT @var_name'.

Used for SHOW COUNT(*) [ WARNINGS | ERROR].

This will crash with a core dump if the variable doesn't exists.

Parameters
pcCurrent parse context
var_nameVariable name
Returns
false if success, true if error

◆ create_table_set_open_action_and_adjust_tables()

void create_table_set_open_action_and_adjust_tables ( LEX lex)

Set proper open mode and table type for element representing target table of CREATE TABLE statement, also adjust statement table list if necessary.

◆ create_temporal_literal()

Item * create_temporal_literal ( THD thd,
const char *  str,
size_t  length,
const CHARSET_INFO cs,
enum_field_types  type,
bool  send_error 
)

Builder for datetime literals: TIME'00:00:00', DATE'2001-01-01', TIMESTAMP'2001-01-01 00:00:00'.

Parameters
thdThe current thread
strCharacter literal
lengthLength of str
csCharacter set of str
typeType of literal (TIME, DATE or DATETIME)
send_errorWhether to generate an error on failure

◆ db_is_default_db()

bool db_is_default_db ( const char *  db,
size_t  db_len,
const THD thd 
)
Returns
whether a database is equal to the connection's default database

◆ dispatch_command()

bool dispatch_command ( THD thd,
const COM_DATA com_data,
enum enum_server_command  command 
)

Perform one connection-level (COM_XXXX) command.

Parameters
thdconnection handle
commandtype of command to perform
com_datacom_data union to store the generated command
Return values
0ok
1request of thread shutdown, i. e. if command is COM_QUIT

Clear the set of flags that are expected to be cleared at the beginning of each command.

Enforce password expiration for all RPC commands, except the following:

COM_QUERY/COM_STMT_PREPARE and COM_STMT_EXECUTE do a more fine-grained check later. COM_STMT_CLOSE and COM_STMT_SEND_LONG_DATA don't return anything. COM_PING only discloses information that the server is running, and that's available through other means. COM_QUIT should work even for expired statements.

◆ do_command()

bool do_command ( THD thd)

Read one command from connection and execute it (query or simple command).

This function is called in loop from thread function.

For profiling to work, it must never be called recursively.

Return values
0success
1request of thread shutdown (see dispatch_command() description)

◆ execute_init_command()

void execute_init_command ( THD thd,
LEX_STRING init_command,
mysql_rwlock_t var_lock 
)

◆ execute_show()

bool execute_show ( THD thd,
TABLE_LIST all_tables 
)

◆ find_native_function_builder()

Create_func * find_native_function_builder ( const LEX_STRING name)

Find the native function builder associated with a given function name.

Parameters
nameThe native function name
Returns
The native function builder associated with the name, or NULL

◆ find_qualified_function_builder()

Create_qfunc * find_qualified_function_builder ( THD thd)

Find the function builder for qualified functions.

Parameters
thdThe current thread
Returns
A function builder for qualified functions

◆ free_items()

void free_items ( Item item)

◆ get_bin_collation()

const CHARSET_INFO* get_bin_collation ( const CHARSET_INFO cs)

◆ get_current_user()

LEX_USER* get_current_user ( THD thd,
LEX_USER user 
)

Retuns information about user or current user.

Parameters
[in]thdthread handler
[in]useruser
Returns
  • On success, return a valid pointer to initialized LEX_USER, which contains user information.
  • On error, return 0.

◆ get_default_definer()

void get_default_definer ( THD thd,
LEX_USER definer 
)

Set the specified definer to the default value, which is the current user in the thread.

Parameters
[in]thdthread handler
[out]definerdefiner

◆ init_sql_command_flags()

void init_sql_command_flags ( void  )

ACL DDLs do not access data-dictionary tables. However, they still need to be marked to avoid autocommit. This is necessary because code which saves GTID state or slave state in the system tables at commit time does statement commit on low-level (see System_table_access::close_table()) and thus can pre-maturely commit DDL otherwise.

Some statements doesn't if the ACL CACHE is disabled using the –skip-grant-tables server option.

◆ is_explainable_query()

bool is_explainable_query ( enum enum_sql_command  command)

◆ is_keyword()

bool is_keyword ( const char *  name,
size_t  len 
)

◆ is_lex_native_function()

bool is_lex_native_function ( const LEX_STRING name)

Check if name is a sql function.

Parameters
namechecked name
Returns
is this a native function or not
Return values
0name is a function
1name isn't a function

◆ is_log_table_write_query()

bool is_log_table_write_query ( enum enum_sql_command  command)

Check if a sql command is allowed to write to log tables.

Parameters
commandThe SQL command
Returns
true if writing is allowed

◆ is_supported_parser_charset()

bool is_supported_parser_charset ( const CHARSET_INFO cs)
inline

◆ is_union()

bool SELECT_LEX_UNIT::is_union ( ) const
inline

◆ is_update_query()

bool is_update_query ( enum enum_sql_command  command)

◆ item_create_cleanup()

void item_create_cleanup ( )

Empty the hash table for native functions.

Note: this code is not thread safe, and is intended to be used at server shutdown only (after thread requests have been executed).

◆ item_create_init()

bool item_create_init ( )

Load the hash table for native functions.

Note: this code is not thread safe, and is intended to be used at server startup only (before going multi-threaded)

Return values
falseOK.
trueAn exception was caught.

◆ killall_non_super_threads()

void killall_non_super_threads ( THD thd)

◆ lex_end()

void lex_end ( LEX lex)

Call this function after preparation and execution of a query.

◆ lex_free()

void lex_free ( void  )

◆ lex_init()

bool lex_init ( void  )

◆ lex_start()

bool lex_start ( THD thd)

Call lex_start() before every query that is to be prepared and executed.

Because of this, it's critical not to do too many things here. (We already do too much)

The function creates a select_lex and a select_lex_unit object. These objects should rather be created by the parser bottom-up.

◆ merge_charset_and_collation()

bool merge_charset_and_collation ( const CHARSET_INFO charset,
const CHARSET_INFO collation,
const CHARSET_INFO **  to 
)

(end of group Runtime_Environment)

Check and merge "[ CHARACTER SET charset ] [ COLLATE collation ]" clause

Parameters
[in]charsetCharacter set pointer or NULL.
[in]collationCollation pointer or NULL.
[out]toResulting character set/collation/NULL on success, untouched on failure.

Check if collation "collation" is applicable to character set "charset".

If "collation" is NULL (e.g. when COLLATE clause is not specified), then simply "charset" is returned in "to". And vice versa, if "charset" is NULL, "collation" is returned in "to".

Returns
false on success, otherwise returns true and pushes an error message on the error stack

◆ merge_sp_var_charset_and_collation()

bool merge_sp_var_charset_and_collation ( const CHARSET_INFO charset,
const CHARSET_INFO collation,
const CHARSET_INFO **  to 
)

◆ mysql_execute_command()

int mysql_execute_command ( THD thd,
bool  first_level 
)

Execute command saved in thd and lex->sql_command.

Parameters
thdThread handle
first_level
Return values
falseOK
trueError

◆ mysql_parse()

void mysql_parse ( THD thd,
Parser_state parser_state 
)

Parse a query.

Parameters
thdCurrent session.
parser_stateParser state.

◆ mysql_reset_thd_for_next_command()

void mysql_reset_thd_for_next_command ( THD thd)

Reset the part of THD responsible for the state of command processing.

This needs to be called before execution of every statement (prepared or conventional). It is not called by substatements of routines.

◆ mysql_test_parse_for_slave()

bool mysql_test_parse_for_slave ( THD thd)

Usable by the replication SQL thread only: just parse a query to know if it can be ignored because of replicate-*-table rules.

Return values
0cannot be ignored
1can be ignored

◆ MYSQLlex()

int MYSQLlex ( YYSTYPE yacc_yylval,
YYLTYPE yylloc,
THD thd 
)

yylex() function implementation for the main parser

Parameters
[out]yacc_yylvalsemantic value of the token being parsed (yylval)
[out]yylloc"location" of the token being parsed (yylloc)
thdTHD
Returns
token number
Note
MYSQLlex remember the following states from the following MYSQLlex():
  • MY_LEX_END Found end of query

◆ parse_sql()

bool parse_sql ( THD thd,
Parser_state parser_state,
Object_creation_ctx creation_ctx 
)

Transform an SQL statement into an AST that is ready for resolving, using the supplied parser state and object creation context.

This is a wrapper() for THD::sql_parser() and should generally be used for AST construction.

The function may optionally generate a query digest, invoke this function as follows:

  THD *thd = ...;
  const char *query_text = ...;
  uint query_length = ...;
  Object_creation_ctx *ctx = ...;
  bool rc;

  Parser_state parser_state;
  if (parser_state.init(thd, query_text, query_length)
  {
    ... handle error
  }

  parser_state.m_input.m_compute_digest= true;

  rc= parse_sql(the, &parser_state, ctx);
  if (! rc)
  {
    unsigned char md5[MD5_HASH_SIZE];
    char digest_text[1024];
    bool truncated;
    const sql_digest_storage *digest= & thd->m_digest->m_digest_storage;

    compute_digest_md5(digest, & md5[0]);
    compute_digest_text(digest, & digest_text[0], sizeof(digest_text), &
truncated);
  }
Parameters
thdThread context.
parser_stateParser state.
creation_ctxObject creation context.
Returns
Error status.
Return values
falseon success.
trueon parsing error.

◆ prepare_index_and_data_dir_path()

bool prepare_index_and_data_dir_path ( THD thd,
const char **  data_file_name,
const char **  index_file_name,
const char *  table_name 
)

prepares the index and data directory path.

Parameters
thdThread handle
data_file_namePathname for data directory
index_file_namePathname for index directory
table_nameTable name to be appended to the pathname specified
Returns
false success
true An error occurred

◆ prepare_schema_table()

int prepare_schema_table ( THD thd,
LEX lex,
Table_ident table_ident,
enum enum_schema_tables  schema_table_idx 
)

Create a TABLE_LIST object for an INFORMATION_SCHEMA table.

This function is used in the parser to convert a SHOW or DESCRIBE table_name command to a SELECT from INFORMATION_SCHEMA. It prepares a SELECT_LEX and a TABLE_LIST object to represent the given command as a SELECT parse tree.

Parameters
thdthread handle
lexcurrent lex
table_identtable alias if it's used
schema_table_idxthe type of the INFORMATION_SCHEMA table to be created
Note
Due to the way this function works with memory and LEX it cannot be used outside the parser (parse tree transformations outside the parser break PS and SP).
Return values
0success
1out of memory or SHOW commands are not allowed in this version of the server.

◆ print_derived_column_names()

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.

Parameters
thdThread handler
strWhere to print
column_namesList to print, or NULL

◆ push_new_name_resolution_context()

bool push_new_name_resolution_context ( Parse_context pc,
TABLE_LIST left_op,
TABLE_LIST right_op 
)

Push a new name resolution context for a JOIN ...

ON clause to the context stack of a query block.

Create a new name resolution context for a JOIN ... ON clause, set the first and last leaves of the list of table references to be used for name resolution, and push the newly created context to the stack of contexts of the query.

Parameters
pccurrent parse context
left_opleft operand of the JOIN
right_oprigth operand of the JOIN
Return values
falseif all is OK
trueif a memory allocation error occurred

◆ set_default_charset()

bool set_default_charset ( HA_CREATE_INFO create_info,
const CHARSET_INFO value 
)

◆ set_default_collation()

bool set_default_collation ( HA_CREATE_INFO create_info,
const CHARSET_INFO value 
)

◆ show_precheck()

bool show_precheck ( THD thd,
LEX lex,
bool  lock 
)

Do special checking for SHOW statements.

Parameters
thdThread context.
lexLEX for SHOW statement.
lockIf true, lock metadata for schema objects
Returns
false if check is successful, true if error

◆ shutdown()

bool shutdown ( THD thd,
enum mysql_enum_shutdown_level  level 
)

Shutdown the mysqld server.

Parameters
thdThread (session) context.
levelShutdown level.
Return values
truesuccess
falseWhen user has insufficient privilege or unsupported shutdown level

◆ some_non_temp_table_to_be_updated()

bool some_non_temp_table_to_be_updated ( THD thd,
TABLE_LIST tables 
)

◆ sqlcom_can_generate_row_events()

bool sqlcom_can_generate_row_events ( enum enum_sql_command  command)

◆ stmt_causes_implicit_commit()

bool stmt_causes_implicit_commit ( const THD thd,
uint  mask 
)

Returns whether the command in thd->lex->sql_command should cause an implicit commit.

An active transaction should be implicitly commited if the statement requires so.

Parameters
thdThread handle.
maskBitmask used for the SQL command match.
Return values
trueThis statement shall cause an implicit commit.
falseThis statement shall not cause an implicit commit.

◆ test_if_data_home_dir()

int test_if_data_home_dir ( const char *  dir)

◆ to_longlong()

longlong to_longlong ( enum_sp_type  val)
inline

◆ to_sp_type()

enum_sp_type to_sp_type ( longlong  val)
inline

◆ to_uint()

uint to_uint ( enum_sp_type  val)
inline

◆ trim_whitespace()

void trim_whitespace ( const CHARSET_INFO cs,
LEX_STRING str 
)

◆ turn_parser_debug_on()

void turn_parser_debug_on ( )

Variable Documentation

◆ binlog_unsafe_map

uint binlog_unsafe_map[256]

◆ command_name

const LEX_STRING command_name[]

◆ EMPTY_CSTR

LEX_CSTRING EMPTY_CSTR

◆ empty_lex_str

const LEX_STRING empty_lex_str

◆ func_array

const std::pair<const char *, Create_func *> func_array[]
static

MySQL native functions.

MAINTAINER:

  • Keep sorted for human lookup. At runtime, a hash table is used.
  • do NOT conditionally (#ifdef, #ifndef) define a function NAME: doing so will cause user code that works against a --without-XYZ binary to fail with name collisions against a --with-XYZ binary.
  • keep 1 line per entry, it makes grep | sort easier
  • Use uppercase (tokens are converted to uppercase before lookup.)

This can't be constexpr because

  • Sun Studio does not allow the Create_func pointer to be constexpr.

◆ index_hint_type_name

const char* index_hint_type_name[]

◆ INITIAL_LEX_PLUGIN_LIST_SIZE

const size_t INITIAL_LEX_PLUGIN_LIST_SIZE = 16

◆ my_charset_utf8mb4_0900_bin

CHARSET_INFO my_charset_utf8mb4_0900_bin

◆ native_functions_hash

const Native_functions_hash* native_functions_hash
static

◆ NULL_CSTR

LEX_CSTRING NULL_CSTR

◆ null_lex_str

const LEX_STRING null_lex_str

LEX_STRING constant for null-string to be used in parser and other places.

◆ s_singleton [1/2]

Create_udf_func Create_udf_func::s_singleton
static

Singleton.

◆ s_singleton [2/2]

Create_sp_func Create_sp_func::s_singleton
static

◆ sp_data_access_name

const LEX_CSTRING sp_data_access_name[]
Initial value:
= {
{STRING_WITH_LEN("CONTAINS SQL")},
{STRING_WITH_LEN("NO SQL")},
{STRING_WITH_LEN("READS SQL DATA")},
{STRING_WITH_LEN("MODIFIES SQL DATA")}}
#define STRING_WITH_LEN(X)
Definition: m_string.h:315

◆ sql_command_flags

uint sql_command_flags[]

Mark all commands that somehow changes a table.

This is used to check number of updates / hour.

sql_command is actually set to SQLCOM_END sometimes so we need the +1 to include it in the array.

See COMMAND_FLAG_xxx for different type of commands 2 - query that returns meaningful ROW_COUNT() - a number of modified rows

◆ trg_new_row_fake_var

sys_var* trg_new_row_fake_var