MySQL 8.4.0
Source Code Documentation
sql_parse.h File Reference
#include <stddef.h>
#include <sys/types.h>
#include "lex_string.h"
#include "my_command.h"
#include "my_sqlcommand.h"
#include "mysql/strings/m_ctype.h"
#include "mysql_com.h"
#include "sql/handler.h"
#include "sql/system_variables.h"
#include "storage/perfschema/terminology_use_previous_enum.h"

Go to the source code of this file.

Classes

class  Command_names
 Map from enumeration values of type enum_server_command to descriptions of type std::string. More...
 

Macros

#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_SHOW_USES_SYSTEM_VIEW   (1U << 21)
 Identifies statements as SHOW commands using INFORMATION_SCHEMA system views. 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...
 

Functions

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...
 
void bind_fields (Item *first)
 Bind Item fields to Field objects. 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_ref 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)
 Returns 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 dispatch_sql_command (THD *thd, Parser_state *parser_state)
 Parse an SQL command from a text string and pass the resulting AST to the query executor. More...
 
void mysql_reset_thd_for_next_command (THD *thd)
 Reset the part of THD responsible for the state of command processing. 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_ref *b, Item *expr)
 Add an ON condition to the second operand of a JOIN ... ON. More...
 
bool push_new_name_resolution_context (Parse_context *pc, Table_ref *left_op, Table_ref *right_op)
 Push a new name resolution context for a JOIN ... ON clause to the context stack of a query block. 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...
 
void statement_id_to_session (THD *thd)
 
bool sqlcom_can_generate_row_events (enum enum_sql_command command)
 
bool is_normal_transaction_boundary_stmt (enum enum_sql_command command)
 This function checks if the sql_command is one that identifies the boundaries (begin, end or savepoint) of a transaction. More...
 
bool is_xa_transaction_boundary_stmt (enum enum_sql_command command)
 This function checks if the sql_command is one that identifies the boundaries (begin, end or savepoint) of an XA transaction. More...
 
bool all_tables_not_ok (THD *thd, Table_ref *tables)
 Returns true if all tables should be ignored. More...
 
bool some_non_temp_table_to_be_updated (THD *thd, Table_ref *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)
 

Variables

uint sql_command_flags []
 Mark all commands that somehow changes a table. More...