MySQL  8.0.15
Source Code Documentation
sql_parse.cc File Reference
#include "sql/sql_parse.h"
#include "my_config.h"
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <algorithm>
#include <atomic>
#include <thread>
#include <utility>
#include "binary_log_types.h"
#include "dur_prop.h"
#include "m_ctype.h"
#include "m_string.h"
#include "my_alloc.h"
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_io.h"
#include "my_loglevel.h"
#include "my_macros.h"
#include "my_psi_config.h"
#include "my_sys.h"
#include "my_table_map.h"
#include "my_thread_local.h"
#include "my_time.h"
#include "mysql/com_data.h"
#include "mysql/components/services/log_builtins.h"
#include "mysql/components/services/log_shared.h"
#include "mysql/components/services/psi_statement_bits.h"
#include "mysql/plugin_audit.h"
#include "mysql/psi/mysql_mutex.h"
#include "mysql/psi/mysql_rwlock.h"
#include "mysql/psi/mysql_statement.h"
#include "mysql/service_mysql_alloc.h"
#include "mysqld_error.h"
#include "mysys_err.h"
#include "nullable.h"
#include "pfs_thread_provider.h"
#include "prealloced_array.h"
#include "sql/auth/auth_acls.h"
#include "sql/auth/auth_common.h"
#include "sql/auth/sql_security_ctx.h"
#include "sql/binlog.h"
#include "sql/current_thd.h"
#include "sql/dd/cache/dictionary_client.h"
#include "sql/dd/dd.h"
#include "sql/dd/dd_schema.h"
#include "sql/dd/dictionary.h"
#include "sql/dd/info_schema/table_stats.h"
#include "sql/debug_sync.h"
#include "sql/derror.h"
#include "sql/discrete_interval.h"
#include "sql/error_handler.h"
#include "sql/events.h"
#include "sql/field.h"
#include "sql/gis/srid.h"
#include "sql/item.h"
#include "sql/item_cmpfunc.h"
#include "sql/item_func.h"
#include "sql/item_subselect.h"
#include "sql/item_timefunc.h"
#include "sql/key_spec.h"
#include "sql/log.h"
#include "sql/log_event.h"
#include "sql/mdl.h"
#include "sql/mem_root_array.h"
#include "sql/mysqld.h"
#include "sql/mysqld_thd_manager.h"
#include "sql/nested_join.h"
#include "sql/opt_hints.h"
#include "sql/opt_trace.h"
#include "sql/parse_location.h"
#include "sql/parse_tree_node_base.h"
#include "sql/parse_tree_nodes.h"
#include "sql/persisted_variable.h"
#include "sql/protocol.h"
#include "sql/protocol_classic.h"
#include "sql/psi_memory_key.h"
#include "sql/query_options.h"
#include "sql/query_result.h"
#include "sql/resourcegroups/resource_group_basic_types.h"
#include "sql/resourcegroups/resource_group_mgr.h"
#include "sql/rpl_context.h"
#include "sql/rpl_filter.h"
#include "sql/rpl_group_replication.h"
#include "sql/rpl_gtid.h"
#include "sql/rpl_handler.h"
#include "sql/rpl_master.h"
#include "sql/rpl_rli.h"
#include "sql/rpl_slave.h"
#include "sql/session_tracker.h"
#include "sql/set_var.h"
#include "sql/sp.h"
#include "sql/sp_cache.h"
#include "sql/sp_head.h"
#include "sql/sql_alter.h"
#include "sql/sql_audit.h"
#include "sql/sql_backup_lock.h"
#include "sql/sql_base.h"
#include "sql/sql_binlog.h"
#include "sql/sql_class.h"
#include "sql/sql_cmd.h"
#include "sql/sql_connect.h"
#include "sql/sql_const.h"
#include "sql/sql_db.h"
#include "sql/sql_digest.h"
#include "sql/sql_digest_stream.h"
#include "sql/sql_error.h"
#include "sql/sql_handler.h"
#include "sql/sql_help.h"
#include "sql/sql_lex.h"
#include "sql/sql_list.h"
#include "sql/sql_prepare.h"
#include "sql/sql_profile.h"
#include "sql/sql_query_rewrite.h"
#include "sql/sql_reload.h"
#include "sql/sql_rename.h"
#include "sql/sql_rewrite.h"
#include "sql/sql_select.h"
#include "sql/sql_show.h"
#include "sql/sql_table.h"
#include "sql/sql_test.h"
#include "sql/sql_trigger.h"
#include "sql/sql_udf.h"
#include "sql/sql_view.h"
#include "sql/strfunc.h"
#include "sql/system_variables.h"
#include "sql/table.h"
#include "sql/table_cache.h"
#include "sql/thd_raii.h"
#include "sql/transaction.h"
#include "sql/transaction_info.h"
#include "sql_string.h"
#include "thr_lock.h"
#include "violite.h"

Classes

class  Kill_non_super_conn
 This class implements callback function used by killall_non_super_threads to kill all threads that do not have the SUPER privilege. More...
 
class  Parser_oom_handler
 

Namespaces

 dd
 The version of the current data dictionary table definitions.
 
 resourcegroups
 

Macros

#define SP_COM_STRING(LP)
 
#define MY_YACC_INIT   1000
 
#define MY_YACC_MAX   32000
 

Functions

static void sql_kill (THD *thd, my_thread_id id, bool only_kill_query)
 
bool command_satisfy_acl_cache_requirement (unsigned command)
 
bool all_tables_not_ok (THD *thd, TABLE_LIST *tables)
 Returns true if all tables should be ignored. More...
 
bool check_database_filters (THD *thd, const char *db, enum_sql_command sql_cmd)
 Checks whether the event for the given database, db, should be ignored or not. More...
 
bool some_non_temp_table_to_be_updated (THD *thd, TABLE_LIST *tables)
 
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 init_sql_command_flags (void)
 
bool sqlcom_can_generate_row_events (enum enum_sql_command command)
 
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...
 
static bool sqlcom_needs_autocommit_off (const LEX *lex)
 Check if statement (typically DDL) needs auto-commit mode temporarily turned off. More...
 
void execute_init_command (THD *thd, LEX_STRING *init_command, mysql_rwlock_t *var_lock)
 
void free_items (Item *item)
 
void cleanup_items (Item *item)
 This works because items are allocated with sql_alloc(). More...
 
bool do_command (THD *thd)
 Read one command from connection and execute it (query or simple command). More...
 
static bool deny_updates_if_read_only_option (THD *thd, TABLE_LIST *all_tables)
 Determine if an attempt to update a non-temporary table while the read-only option was enabled has been made. More...
 
static bool is_timer_applicable_to_statement (THD *thd)
 Check whether max statement time is applicable to statement or not. More...
 
static void check_secondary_engine_statement (THD *thd, Parser_state *parser_state, const char *query_string, size_t query_length)
 Check if a statement was unsuccessfully offloaded to a secondary engine and should be reprepared against the primary storage engine. 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 shutdown (THD *thd, enum mysql_enum_shutdown_level level)
 Shutdown the mysqld server. More...
 
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...
 
bool alloc_query (THD *thd, const char *packet, size_t packet_length)
 Read query from packet and store in thd->query. More...
 
static bool sp_process_definer (THD *thd)
 
static bool lock_tables_open_and_lock_tables (THD *thd, TABLE_LIST *tables)
 Auxiliary call that opens and locks tables for LOCK TABLES statement and initializes the list of locked tables. More...
 
static void binlog_gtid_end_transaction (THD *thd)
 This is a wrapper for MYSQL_BIN_LOG::gtid_end_transaction. More...
 
int mysql_execute_command (THD *thd, bool first_level)
 Execute command saved in thd and lex->sql_command. More...
 
bool show_precheck (THD *thd, LEX *lex, bool lock)
 Do special checking for SHOW statements. More...
 
bool execute_show (THD *thd, TABLE_LIST *all_tables)
 
bool my_yyoverflow (short **yyss, YYSTYPE **yyvs, YYLTYPE **yyls, ulong *yystacksize)
 
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 mysql_parse (THD *thd, Parser_state *parser_state, bool force_primary_storage_engine)
 Parse a query. 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...
 
void add_to_list (SQL_I_List< ORDER > &list, ORDER *order)
 save order by and tables in own lists. More...
 
static bool reparse_common_table_expr (THD *thd, const LEX_STRING &text, uint text_offset, PT_subquery **node)
 Produces a PT_subquery object from a subquery's text. 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 add_join_on (TABLE_LIST *b, Item *expr)
 Add an ON condition to the second operand of a JOIN ... More...
 
const CHARSET_INFOget_bin_collation (const CHARSET_INFO *cs)
 
static uint kill_one_thread (THD *thd, my_thread_id id, bool only_kill_query)
 kill on thread. More...
 
void killall_non_super_threads (THD *thd)
 
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...
 
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)
 
Itemall_any_subquery_creator (Item *left_expr, chooser_compare_func_creator cmp, bool all, SELECT_LEX *select_lex)
 Construct ALL/ANY/SOME subquery Item. 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...
 
Itemnegate_expression (Parse_context *pc, Item *expr)
 negate given expression. 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...
 
static bool check_string_byte_length (const LEX_CSTRING &str, const char *err_msg, size_t max_byte_length)
 Check that byte length of a string does not exceed some limit. 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)
 
int test_if_data_home_dir (const char *dir)
 
bool check_host_name (const LEX_CSTRING &str)
 Check that host name string is valid. More...
 
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...
 
const CHARSET_INFOmerge_charset_and_collation (const CHARSET_INFO *cs, const CHARSET_INFO *cl)
 (end of group Runtime_Environment) More...
 
bool merge_sp_var_charset_and_collation (const CHARSET_INFO **to, const CHARSET_INFO *cs, const CHARSET_INFO *cl)
 

Variables

const LEX_STRING command_name []
 
uint sql_command_flags [SQLCOM_END+1]
 Mark all commands that somehow changes a table. More...
 
uint server_command_flags [COM_END+1]