MySQL 8.4.3
Source Code Documentation
THD Class Reference

For each client connection we create a separate thread with THD serving as a thread/connection descriptor. More...

#include <sql_lexer_thd.h>

Inheritance diagram for THD:
[legend]

Classes

class  Attachable_trx
 Class representing read-only attachable transaction, encapsulates knowledge how to backup state of current transaction, start read-only attachable transaction in SE, finalize it and then restore state of original transaction back. More...
 
class  Attachable_trx_rw
 A derived from THD::Attachable_trx class allows updates in the attachable transaction. More...
 
class  Query_plan
 Query plan for EXPLAINable commands, should be locked with LOCK_query_plan before using. More...
 
struct  System_variables
 
struct  Transaction_state
 An utility struct for Attachable_trx. More...
 

Public Types

enum  binlog_filter_state { BINLOG_FILTER_UNKNOWN , BINLOG_FILTER_CLEAR , BINLOG_FILTER_SET }
 
enum  enum_reset_lex { RESET_LEX , DO_NOT_RESET_LEX }
 
enum  Commit_error {
  CE_NONE = 0 , CE_FLUSH_ERROR , CE_FLUSH_GNO_EXHAUSTED_ERROR , CE_SYNC_ERROR ,
  CE_COMMIT_ERROR , CE_ERROR_COUNT
}
 
enum  killed_state {
  NOT_KILLED = 0 , KILL_CONNECTION = ER_SERVER_SHUTDOWN , KILL_QUERY = ER_QUERY_INTERRUPTED , KILL_TIMEOUT = ER_QUERY_TIMEOUT ,
  KILLED_NO_VALUE
}
 
enum  enum_binlog_query_type { ROW_QUERY_TYPE , STMT_QUERY_TYPE , QUERY_TYPE_COUNT }
 
enum  Se_GTID_flag : size_t {
  SE_GTID_PIN = 0 , SE_GTID_CLEANUP , SE_GTID_PERSIST , SE_GTID_RESET_LOG ,
  SE_GTID_PERSIST_EXPLICIT , SE_GTID_MAX
}
 SE GTID persistence flag types. More...
 
using sql_mode_t = uint64_t
 
using Se_GTID_flagset = std::bitset< SE_GTID_MAX >
 
- Public Types inherited from Query_arena
enum  enum_state {
  STMT_INITIALIZED = 0 , STMT_INITIALIZED_FOR_SP = 1 , STMT_PREPARED = 2 , STMT_REGULAR_EXECUTION = 3 ,
  STMT_EXECUTED = 4 , STMT_ERROR = -1
}
 
- Public Types inherited from Open_tables_state
enum  enum_flags { BACKUPS_AVAIL = (1U << 0) , SYSTEM_TABLES = (1U << 1) }
 

Public Member Functions

const CHARSET_INFOcharset () const
 
bool convert_string (LEX_STRING *, const CHARSET_INFO *, const char *, size_t, const CHARSET_INFO *, bool=false)
 
void * alloc (size_t size)
 
char * strmake (const char *str, size_t size) const
 
dd::cache::Dictionary_clientdd_client () const
 
bool is_binlog_applier () const
 The function checks whether the thread is processing queries from binlog, as automatically generated by mysqlbinlog. More...
 
void rpl_detach_engine_ha_data ()
 When the thread is a binlog or slave applier it detaches the engine ha_data associated with it and memorizes the fact of that. More...
 
void set_secondary_engine_statement_context (std::unique_ptr< Secondary_engine_statement_context > context)
 
Secondary_engine_statement_contextsecondary_engine_statement_context ()
 
void rpl_reattach_engine_ha_data ()
 When the thread is a binlog or slave applier it reattaches the engine ha_data associated with it and memorizes the fact of that. More...
 
bool is_engine_ha_data_detached () const
 
void reset_for_next_command ()
 
void clear_current_query_costs ()
 Clear the query costs attributes for the current query. More...
 
void save_current_query_costs ()
 Save the current query costs attributes in the thread session status. More...
 
void clear_copy_status_var ()
 Clear copy of the status variables. More...
 
void copy_status_var (System_status_var *dst_var)
 Copy status variables into a structure pointed by the specified pointer and keep track of the pointer internally. More...
 
void reset_copy_status_var ()
 Copy status variables into a structure pointed by the specified pointer passed into copy_status_var method call. More...
 
void lock_query_plan ()
 Locks the query plan of this THD. More...
 
void unlock_query_plan ()
 
Security_contextsecurity_context () const
 
void set_security_context (Security_context *sctx)
 
const Protocolget_protocol () const
 
Protocolget_protocol ()
 
SSL_handle get_ssl () const
 
const Protocol_classicget_protocol_classic () const
 Asserts that the protocol is of type text or binary and then returns the m_protocol casted to Protocol_classic. More...
 
Protocol_classicget_protocol_classic ()
 
const LEX_CSTRINGcatalog () const
 
void set_catalog (const LEX_CSTRING &catalog)
 
void enter_stage (const PSI_stage_info *stage, PSI_stage_info *old_stage, const char *calling_func, const char *calling_file, const unsigned int calling_line) SUPPRESS_TSAN
 
const char * proc_info () const
 
const char * proc_info_session (THD *invoking_thd) const
 Return the m_proc_info, possibly using the string of an older server release, according to @session.terminology_use_previous. More...
 
void set_proc_info (const char *proc_info)
 
PSI_stage_key get_current_stage_key () const
 
void enable_low_level_commit_ordering ()
 Enables ordering in ha_commit_low. More...
 
void disable_low_level_commit_ordering ()
 Enables ordering in ha_commit_low. More...
 
bool is_low_level_commit_ordering_enabled () const
 Obtains flag indicating whether additional ordering in the ha_commit_low function is enabled. More...
 
void set_admin_connection (bool admin)
 
bool is_admin_connection () const
 
ulonglong get_lock_usec ()
 
void inc_lock_usec (ulonglong usec)
 
void push_lock_usec (ulonglong &top)
 
void pop_lock_usec (ulonglong top)
 
Ha_dataget_ha_data (int slot)
 Retrieve Ha_data for a given slot. More...
 
void backup_ha_data (Prealloced_array< Ha_data, PREALLOC_NUM_HA > *backup)
 Copy ha_data into the provided argument. More...
 
void restore_ha_data (const Prealloced_array< Ha_data, PREALLOC_NUM_HA > &backup)
 Restore ha_data from the provided backup copy. More...
 
void set_next_event_pos (const char *_filename, ulonglong _pos)
 
void clear_next_event_pos ()
 
int binlog_setup_trx_data ()
 
bool binlog_configure_trx_cache_size (ulong new_size)
 Configure size of binlog transaction cache. More...
 
int binlog_write_table_map (TABLE *table, bool is_transactional, bool binlog_rows_query)
 This function writes a table map to the binary log. More...
 
int binlog_write_row (TABLE *table, bool is_transactional, const uchar *new_data, const unsigned char *extra_row_info)
 
int binlog_delete_row (TABLE *table, bool is_transactional, const uchar *old_data, const unsigned char *extra_row_info)
 
int binlog_update_row (TABLE *table, bool is_transactional, const uchar *old_data, const uchar *new_data, const uchar *extra_row_info)
 
void set_server_id (uint32 sid)
 
template<class RowsEventT >
Rows_log_eventbinlog_prepare_pending_rows_event (TABLE *table, uint32 serv_id, size_t needed, bool is_transactional, const unsigned char *extra_row_info, uint32 source_part_id=INT_MAX)
 
Rows_log_eventbinlog_get_pending_rows_event (bool is_transactional) const
 This function retrieves a pending row event from a cache which is specified through the parameter is_transactional. More...
 
int binlog_flush_pending_rows_event (bool stmt_end)
 
int binlog_flush_pending_rows_event (bool stmt_end, bool is_transactional)
 
int is_current_stmt_binlog_format_row () const
 Determine the binlog format of the current statement. More...
 
bool is_current_stmt_binlog_disabled () const
 Determine if binlogging is currently disabled for this session. More...
 
bool is_current_stmt_binlog_log_replica_updates_disabled () const
 Determine if binlogging is currently disabled for this session. More...
 
bool is_current_stmt_binlog_enabled_and_caches_empty () const
 Checks whether binlog caches are disabled (binlog does not cache data) or empty in case binloggging is enabled in the current call to this function. More...
 
bool is_current_stmt_binlog_row_enabled_with_write_set_extraction () const
 Determine if binloging is enabled in row format and write set extraction is enabled for this session. More...
 
bool optimizer_switch_flag (ulonglong flag) const
 Tells whether the given optimizer_switch flag is on. More...
 
void reset_binlog_local_stmt_filter ()
 
void clear_binlog_local_stmt_filter ()
 
void set_binlog_local_stmt_filter ()
 
binlog_filter_state get_binlog_local_stmt_filter () const
 
const NETget_net () const
 
void set_skip_readonly_check ()
 
void set_skip_transaction_read_only_check ()
 
bool is_cmd_skip_readonly () const
 
bool is_cmd_skip_transaction_read_only () const
 
void reset_skip_readonly_check ()
 
void reset_skip_transaction_read_only_check ()
 
void issue_unsafe_warnings ()
 Auxiliary method used by binlog_query() to raise warnings. More...
 
uint get_binlog_table_maps () const
 
void clear_binlog_table_maps ()
 
List< char > * get_binlog_accessed_db_names () const
 
void add_to_binlog_accessed_dbs (const char *db)
 
bool is_applier_thread () const
 
Transaction_ctxget_transaction ()
 
const Transaction_ctxget_transaction () const
 
void set_transaction (Transaction_ctx *transaction_ctx)
 Changes the Transaction_ctx instance within THD-object. More...
 
void record_first_successful_insert_id_in_cur_stmt (ulonglong id_arg)
 
ulonglong read_first_successful_insert_id_in_prev_stmt (void)
 
void reset_first_successful_insert_id ()
 
void force_one_auto_inc_interval (ulonglong next_id)
 
longlong get_row_count_func () const
 
void set_row_count_func (longlong row_count_func)
 
void set_user_connect (USER_CONN *uc)
 
const USER_CONNget_user_connect () const
 
void increment_user_connections_counter ()
 
void decrement_user_connections_counter ()
 
void increment_con_per_hour_counter ()
 
void increment_updates_counter ()
 
void increment_questions_counter ()
 
void time_out_user_resource_limits ()
 
ha_rows get_sent_row_count () const
 
ha_rows get_examined_row_count () const
 
void set_sent_row_count (ha_rows count)
 
void inc_sent_row_count (ha_rows count)
 
void inc_examined_row_count (ha_rows count)
 
void inc_status_created_tmp_disk_tables ()
 
void inc_status_created_tmp_tables ()
 
void inc_status_select_full_join ()
 
void inc_status_select_full_range_join ()
 
void inc_status_select_range ()
 
void inc_status_select_range_check ()
 
void inc_status_select_scan ()
 
void inc_status_sort_merge_passes ()
 
void inc_status_sort_range ()
 
void inc_status_sort_rows (ha_rows count)
 
void inc_status_sort_scan ()
 
void set_status_no_index_used ()
 
void set_status_no_good_index_used ()
 
void set_new_thread_id ()
 Assign a value to m_thread_id by calling Global_THD_manager::get_new_thread_id(). More...
 
my_thread_id thread_id () const
 
bool is_system_thread () const
 
bool is_dd_system_thread () const
 
bool is_initialize_system_thread () const
 
bool is_init_file_system_thread () const
 
bool is_bootstrap_system_thread () const
 
bool is_server_upgrade_thread () const
 
 THD (bool enable_plugins=true)
 
 ~THD () override
 
void release_resources ()
 Release most resources, prior to THD destruction. More...
 
bool release_resources_done () const
 
bool is_being_disposed () const
 Check if THD is being disposed (i.e. More...
 
void init_query_mem_roots ()
 Initialize memory roots necessary for query processing and (!) pre-allocate memory for it. More...
 
void cleanup_connection (void)
 
void cleanup_after_query ()
 
void store_globals ()
 
void restore_globals ()
 
void set_active_vio (Vio *vio)
 
void set_ssl (Vio *vio)
 
void clear_active_vio ()
 
void set_clone_vio (Vio *vio)
 Set active clone network Vio for remote clone. More...
 
void clear_clone_vio ()
 Clear clone network Vio for remote clone. More...
 
bool check_clone_vio ()
 Check if clone network Vio is active. More...
 
void shutdown_clone_vio ()
 Shutdown clone vio, if active. More...
 
enum_vio_type get_vio_type () const
 
void shutdown_active_vio ()
 
void awake (THD::killed_state state_to_set)
 Awake a thread. More...
 
void disconnect (bool server_shutdown=false)
 Disconnect the associated communication endpoint. More...
 
int binlog_query (enum_binlog_query_type qtype, const char *query, size_t query_len, bool is_trans, bool direct, bool suppress_use, int errcode)
 Log the current query. More...
 
void enter_cond (mysql_cond_t *cond, mysql_mutex_t *mutex, const PSI_stage_info *stage, PSI_stage_info *old_stage, const char *src_function, const char *src_file, int src_line) override
 Enter a condition wait. More...
 
void exit_cond (const PSI_stage_info *stage, const char *src_function, const char *src_file, int src_line) override
 End a wait on a condition. More...
 
int is_killed () const final
 Has the owner thread been killed? More...
 
bool might_have_commit_order_waiters () const final
 Indicates that owner thread might have some commit order (non-MDL) waits for it which are still taken into account by MDL deadlock detection, even in cases when it doesn't have any MDL locks acquired and therefore can't have any MDL waiters. More...
 
THDget_thd () override
 Within MDL subsystem this one is only used for DEBUG_SYNC. More...
 
void notify_shared_lock (MDL_context_owner *ctx_in_use, bool needs_thr_lock_abort) override
 A callback to the server internals that is used to address special cases of the locking protocol. More...
 
bool notify_hton_pre_acquire_exclusive (const MDL_key *mdl_key, bool *victimized) override
 Notify/get permission from interested storage engines before acquiring exclusive lock for the key. More...
 
void notify_hton_post_release_exclusive (const MDL_key *mdl_key) override
 Notify interested storage engines that we have just released exclusive lock for the key. More...
 
uint get_rand_seed () const override
 Provide thread specific random seed for MDL_context's PRNG. More...
 
bool is_strict_mode () const
 
const CHARSET_INFOcollation ()
 
Time_zonetime_zone ()
 
time_t query_start_in_secs () const
 
my_timeval query_start_timeval_trunc (uint decimals)
 
void set_time ()
 
void set_time (const struct timeval *t)
 
bool is_fsp_truncate_mode () const
 
void update_slow_query_status ()
 Evaluate the current time, and if it exceeds the long-query-time setting, mark the query as slow. More...
 
ulonglong found_rows () const
 
void update_previous_found_rows ()
 
bool in_multi_stmt_transaction_mode () const
 Returns true if session is in a multi-statement transaction mode. More...
 
bool in_active_multi_stmt_transaction () const
 true if the session is in a multi-statement transaction mode ( More...
 
bool fill_information_schema_tables () const
 
bool convert_string (LEX_STRING *to, const CHARSET_INFO *to_cs, const char *from, size_t from_length, const CHARSET_INFO *from_cs, bool report_error=false)
 
int send_explain_fields (Query_result *result)
 
void clear_error ()
 Clear the current error, if any. More...
 
bool is_classic_protocol () const
 
bool is_connected (bool use_cached_connection_alive=false) final
 Return false if connection to client is broken. More...
 
void fatal_error ()
 Mark the current error as fatal. More...
 
bool is_fatal_error () const
 
bool is_error () const
 true if there is an error in the error stack. More...
 
Diagnostics_areaget_stmt_da ()
 Returns first Diagnostics Area for the current statement. More...
 
const Diagnostics_areaget_stmt_da () const
 Returns first Diagnostics Area for the current statement. More...
 
const Diagnostics_areaget_stacked_da () const
 Returns the second Diagnostics Area for the current statement. More...
 
Diagnostics_areaget_parser_da ()
 Returns thread-local Diagnostics Area for parsing. More...
 
Diagnostics_areaget_query_rewrite_plugin_da ()
 Returns thread-local Diagnostics Area to be used by query rewrite plugins. More...
 
void push_diagnostics_area (Diagnostics_area *da, bool copy_conditions=true)
 Push the given Diagnostics Area on top of the stack, making it the new first Diagnostics Area. More...
 
void pop_diagnostics_area ()
 Pop the top DA off the Diagnostics Area stack. More...
 
void push_protocol (Protocol *protocol)
 Inserts the new protocol at the top of the protocol stack, and make it the current protocol for this thd. More...
 
template<typename ProtocolClass >
void push_protocol (const std::unique_ptr< ProtocolClass > &protocol)
 
void pop_protocol ()
 Pops the top protocol of the Protocol stack and sets the previous one as the current protocol. More...
 
const CHARSET_INFOcharset () const
 
void update_charset ()
 
void change_item_tree (Item **place, Item *new_value)
 Record a transient change to a pointer to an Item within another Item. More...
 
void nocheck_register_item_tree_change (Item **place, Item *new_value)
 Remember that place was updated with new_value so it can be restored by rollback_item_tree_changes(). More...
 
void rollback_item_tree_changes ()
 Restore locations set by calls to nocheck_register_item_tree_change(). More...
 
void end_statement ()
 
void send_kill_message () const
 
void reset_n_backup_open_tables_state (Open_tables_backup *backup, uint add_state_flags)
 
void restore_backup_open_tables_state (Open_tables_backup *backup)
 
void reset_sub_statement_state (Sub_statement_state *backup, uint new_state)
 
void restore_sub_statement_state (Sub_statement_state *backup)
 
void begin_attachable_ro_transaction ()
 Start a read-only attachable transaction. More...
 
void begin_attachable_rw_transaction ()
 Start a read-write attachable transaction. More...
 
void end_attachable_transaction ()
 End an active attachable transaction. More...
 
bool is_attachable_ro_transaction_active () const
 
bool is_attachable_transaction_active () const
 
bool is_attachable_rw_transaction_active () const
 
void set_current_stmt_binlog_format_row_if_mixed ()
 
void set_current_stmt_binlog_format_row ()
 
void clear_current_stmt_binlog_format_row ()
 
void reset_current_stmt_binlog_format_row ()
 
void set_original_commit_timestamp_for_slave_thread ()
 Copies variables.original_commit_timestamp to ((Slave_worker *)rli_slave)->original_commit_timestamp, if this is a slave thread. More...
 
Gtid_setget_gtid_next_list ()
 Return the value of @gtid_next_list: either a Gtid_set or NULL. More...
 
const Gtid_setget_gtid_next_list_const () const
 Return the value of @gtid_next_list: either a Gtid_set or NULL. More...
 
bool is_binlog_cache_empty (bool is_transactional) const
 Return true if the statement/transaction cache is currently empty, false otherwise. More...
 
void pin_gtid ()
 Defer freeing owned GTID and TSID till unpinned. More...
 
void unpin_gtid ()
 Unpin and free GTID and TSID. More...
 
bool is_one_phase_commit ()
 
void set_log_reset ()
 Set when binlog reset operation is started. More...
 
void clear_log_reset ()
 Cleared after flushing SE logs during binlog reset. More...
 
bool is_log_reset () const
 
void set_gtid_persisted_by_se ()
 Set by SE when it guarantees GTID persistence. More...
 
void request_persist_gtid_by_se ()
 Request SE to persist GTID explicitly. More...
 
void reset_gtid_persisted_by_se ()
 Reset by SE at transaction end after persisting GTID. More...
 
bool se_persists_gtid () const
 
bool se_persists_gtid_explicit () const
 
bool is_extrenal_xa () const
 
void clear_owned_gtids ()
 
bool owned_gtid_is_empty ()
 
const LEX_CSTRINGdb () const
 
bool set_db (const LEX_CSTRING &new_db)
 Set the current database; use deep copy of C-string. More...
 
void reset_db (const LEX_CSTRING &new_db)
 Set the current database; use shallow copy of C-string. More...
 
bool copy_db_to (char const **p_db, size_t *p_db_length) const
 
bool copy_db_to (char **p_db, size_t *p_db_length) const
 
resourcegroups::Resource_group_ctxresource_group_ctx ()
 Get resource group context. More...
 
void set_psi (PSI_thread *psi)
 Save the performance schema thread instrumentation associated with this user session. More...
 
PSI_threadget_psi () const
 Read the performance schema thread instrumentation associated with this user session. More...
 
const Internal_error_handlerget_internal_handler () const
 
void push_internal_handler (Internal_error_handler *handler)
 Add an internal error handler to the thread execution context. More...
 
Internal_error_handlerpop_internal_handler ()
 Remove the error handler last pushed. More...
 
void raise_error (uint code)
 Raise an exception condition. More...
 
void raise_error_printf (uint code,...)
 Raise an exception condition, with a formatted message. More...
 
void raise_warning (uint code)
 Raise a completion condition (warning). More...
 
void raise_warning_printf (uint code,...)
 Raise a completion condition (warning), with a formatted message. More...
 
void raise_note (uint code)
 Raise a completion condition (note), with a fixed message. More...
 
void raise_note_printf (uint code,...)
 Raise an completion condition (note), with a formatted message. More...
 
void set_command (enum enum_server_command command)
 
enum enum_server_command get_command () const
 
void debug_assert_query_locked () const
 For safe and protected access to the query string, the following rules should be followed: 1: Only the owner (current_thd) can set the query string. More...
 
const LEX_CSTRINGquery () const
 
const String normalized_query ()
 The current query in normalized form. More...
 
void set_query_for_display (const char *query_arg, size_t query_length_arg)
 Set query to be displayed in performance schema (threads table etc.). More...
 
void reset_query_for_display ()
 Reset query string to be displayed in PFS. More...
 
bool safe_to_display () const
 
void set_safe_display (bool safe)
 Set if the query string to be safe to display. More...
 
void set_query (const char *query_arg, size_t query_length_arg)
 Assign a new value to thd->m_query_string. More...
 
void set_query (LEX_CSTRING query_arg)
 
void reset_query ()
 
void swap_rewritten_query (String &query_arg)
 Set the rewritten query (with passwords obfuscated etc.) on the THD. More...
 
const Stringrewritten_query () const
 Get the rewritten query (with passwords obfuscated etc.) from the THD. More...
 
void reset_rewritten_query ()
 Reset thd->m_rewritten_query. More...
 
void set_query_id (query_id_t new_query_id)
 Assign a new value to thd->query_id. More...
 
void set_open_tables (TABLE *open_tables_arg)
 Assign a new value to open_tables. More...
 
void set_is_killable (bool is_killable_arg)
 Assign a new value to is_killable Protected with the LOCK_thd_data mutex. More...
 
void enter_locked_tables_mode (enum_locked_tables_mode mode_arg)
 
void leave_locked_tables_mode ()
 Leave explicit LOCK TABLES or prelocked mode and restore value of transaction sentinel in MDL subsystem. More...
 
int decide_logging_format (Table_ref *tables)
 Decide on logging format to use for the statement and issue errors or warnings as needed. More...
 
bool is_dml_gtid_compatible (bool some_transactional_table, bool some_non_transactional_table, bool non_transactional_tables_are_tmp)
 is_dml_gtid_compatible() and is_ddl_gtid_compatible() check if the statement that is about to be processed will safely get a GTID. More...
 
bool is_ddl_gtid_compatible ()
 
void binlog_invoker ()
 
bool need_binlog_invoker () const
 
void get_definer (LEX_USER *definer)
 
void set_invoker (const LEX_STRING *user, const LEX_STRING *host)
 
LEX_CSTRING get_invoker_user () const
 
LEX_CSTRING get_invoker_host () const
 
bool has_invoker () const
 
void mark_transaction_to_rollback (bool all)
 Mark transaction to rollback and mark error as fatal to a sub-statement. More...
 
void init_cost_model ()
 Initialize the optimizer cost model. More...
 
const Cost_model_servercost_model () const
 Retrieve the optimizer cost model for this connection. More...
 
void syntax_error ()
 
void syntax_error (const char *format,...)
 Push an error message into MySQL diagnostic area with line number and position. More...
 
void syntax_error (int mysql_errno,...)
 Push an error message into MySQL diagnostic area with line number and position. More...
 
void syntax_error_at (const POS &location)
 
void syntax_error_at (const POS &location, const char *format,...)
 Push a syntax error message into MySQL diagnostic area with line and position information. More...
 
void syntax_error_at (const POS &location, int mysql_errno,...)
 Push a syntax error message into MySQL diagnostic area with line and position information. More...
 
void vsyntax_error_at (const POS &location, const char *format, va_list args)
 
void vsyntax_error_at (const char *pos_in_lexer_raw_buffer, const char *format, va_list args)
 Push a syntax error message into MySQL diagnostic area with line number and position. More...
 
bool send_result_metadata (const mem_root_deque< Item * > &list, uint flags)
 Send name and type of result to client. More...
 
bool send_result_set_row (const mem_root_deque< Item * > &row_items)
 Send one result set row. More...
 
void send_statement_status ()
 
void claim_memory_ownership (bool claim)
 Claim all the memory used by the THD object. More...
 
bool is_a_srv_session () const
 
void mark_as_srv_session ()
 
const st_plugin_intget_plugin () const
 Returns the plugin, the thd belongs to. More...
 
void set_plugin (const st_plugin_int *plugin)
 Sets the plugin id to the value provided as parameter. More...
 
uint get_tmp_table_seq_id ()
 
void set_tmp_table_seq_id (uint arg)
 
bool is_plugin_fake_ddl () const
 
void mark_plugin_fake_ddl (bool flag)
 
void set_waiting_for_disk_space (bool waiting)
 Set the waiting_for_disk_space flag. More...
 
bool is_waiting_for_disk_space () const
 Returns the current waiting_for_disk_space flag value. More...
 
bool sql_parser ()
 Call parser to transform statement into a parse tree. More...
 
void set_secondary_engine_optimization (Secondary_engine_optimization state)
 Enables or disables use of secondary storage engines in this session. More...
 
Secondary_engine_optimization secondary_engine_optimization () const
 Can secondary storage engines be used for query execution in this session? More...
 
bool is_secondary_storage_engine_eligible () const
 Checks if queries in this session can use a secondary storage engine for execution. More...
 
void set_secondary_engine_forced (bool forced)
 Indicate whether secondary storage engine is forced for this execution. More...
 
bool is_secondary_engine_forced () const
 
bool is_system_user ()
 Returns if the user of the session has the SYSTEM_USER privilege or not. More...
 
void set_system_user (bool system_user_flag)
 Sets the system_user flag atomically for the current session. More...
 
bool is_connection_admin ()
 Returns if the user of the session has the CONNECTION_ADMIN privilege or not. More...
 
void set_connection_admin (bool connection_admin_flag)
 Sets the connection_admin flag atomically for the current session. More...
 
void copy_table_access_properties (THD *thd)
 Copy session properties that affect table access from the parent session to the current session. More...
 
void enable_mem_cnt ()
 
void disable_mem_cnt ()
 
bool is_mem_cnt_error ()
 
bool add_external (unsigned int slot, void *data)
 
void * fetch_external (unsigned int slot)
 
void release_external_store ()
 
Event_tracking_data get_event_tracking_data ()
 
bool check_event_subscribers (Event_tracking_class event, unsigned long subevent, bool check_audited)
 
bool event_notify (struct st_mysql_event_generic *event_data)
 
void refresh_reference_caches ()
 
void set_trans_pos (const char *file, my_off_t pos)
 Functions to set and get transaction position. More...
 
void get_trans_pos (const char **file_var, my_off_t *pos_var) const
 
void get_trans_fixed_pos (const char **file_var, my_off_t *pos_var) const
 
- Public Member Functions inherited from MDL_context_owner
virtual ~MDL_context_owner ()=default
 
- Public Member Functions inherited from Query_arena
 Query_arena (MEM_ROOT *mem_root_arg, enum enum_state state_arg)
 
 Query_arena ()
 
virtual ~Query_arena ()=default
 
Itemitem_list () const
 
void reset_item_list ()
 
void set_item_list (Item *item)
 
void add_item (Item *item)
 
void free_items ()
 
void set_state (enum_state state_arg)
 
enum_state get_state () const
 
bool is_stmt_prepare () const
 
bool is_stmt_prepare_or_first_sp_execute () const
 
bool is_stmt_prepare_or_first_stmt_execute () const
 
bool is_regular () const
 
void * alloc (size_t size)
 
void * mem_calloc (size_t size)
 
template<typename T >
T * alloc_typed ()
 
template<typename T >
T * memdup_typed (const T *mem)
 
char * mem_strdup (const char *str)
 
char * strmake (const char *str, size_t size) const
 
LEX_CSTRING strmake (LEX_CSTRING str)
 
void * memdup (const void *str, size_t size)
 
void set_query_arena (const Query_arena &set)
 Copies memory-managing members from set. More...
 
void swap_query_arena (const Query_arena &source, Query_arena *backup)
 Copy the current arena to backup and set the current arena to match source More...
 
- Public Member Functions inherited from Open_tables_state
Reprepare_observerget_reprepare_observer () const
 
void push_reprepare_observer (Reprepare_observer *o)
 
Reprepare_observerpop_reprepare_observer ()
 
void reset_reprepare_observers ()
 
 Open_tables_state ()
 This constructor initializes Open_tables_state instance which can only be used as backup storage. More...
 
void set_open_tables_state (Open_tables_state *state)
 
void reset_open_tables_state ()
 

Public Attributes

MEM_ROOTmem_root {nullptr}
 
System_variables variables
 
Parser_statem_parser_state
 Internal parser state. More...
 
Thd_mem_cnt m_mem_cnt
 Controlled memory stats for this session. More...
 
MDL_context mdl_context
 
enum enum_mark_columns mark_used_columns
 MARK_COLUMNS_NONE: Means mark_used_columns is not set and no indicator to handler of fields used is set MARK_COLUMNS_READ: Means a bit in read set is set to inform handler that the field is to be read. More...
 
Access_bitmask want_privilege
 Used by Item::check_column_privileges() to tell which privileges to check for. More...
 
LEXlex
 
Relay_log_inforli_fake
 
Relay_log_inforli_slave
 
bool tx_commit_pending
 
NET_SERVER m_net_server_extension
 Additional network instrumentation for the server only. More...
 
collation_unordered_map< std::string, unique_ptr_with_deleter< user_var_entry > > user_vars {system_charset_info, key_memory_user_var_entry}
 Hash for user variables. More...
 
struct rand_struct rand
 
struct System_variables variables
 
struct System_status_var status_var
 
struct System_status_varcopy_status_var_ptr
 
struct System_status_varinitial_status_var
 
bool status_var_aggregated
 
std::vector< char > m_connection_attributes
 Session's connection attributes for the connected client. More...
 
double m_current_query_cost
 Current query cost. More...
 
ulonglong m_current_query_partial_plans
 Current query partial plans. More...
 
THR_LOCK_INFO lock_info
 
mysql_mutex_t LOCK_thd_data
 Protects THD data accessed from other threads. More...
 
mysql_mutex_t LOCK_thd_query
 Protects THD::m_query_string. More...
 
mysql_mutex_t LOCK_thd_sysvar
 Protects THD::variables while being updated. More...
 
bool for_debug_only_is_set_persist_options {false}
 
mysql_mutex_t LOCK_thd_protocol
 Protects THD::m_protocol when it gets removed in x plugin. More...
 
mysql_mutex_t LOCK_thd_security_ctx
 Protects THD::m_security_ctx from inspection (e.g. More...
 
Prepared_statement_map stmt_map
 All prepared statements of this connection. More...
 
const char * thread_stack
 
Security_context m_main_security_ctx
 
Security_contextm_security_ctx
 
List< Security_contextm_view_ctx_list
 
bool m_disable_password_validation
 
std::unique_ptr< Protocol_textprotocol_text
 
std::unique_ptr< Protocol_binaryprotocol_binary
 
class THD::Query_plan query_plan
 
const char * where
 
ulong max_client_packet_length
 
collation_unordered_map< std::string, unique_ptr_my_free< Table_ref > > handler_tables_hash
 
malloc_unordered_map< std::string, User_level_lock * > ull_hash
 
uint dbug_sentry
 
bool is_killable
 
mysql_mutex_t LOCK_current_cond
 Mutex protecting access to current_mutex and current_cond. More...
 
std::atomic< mysql_mutex_t * > current_mutex
 The mutex used with current_cond. More...
 
std::atomic< mysql_cond_t * > current_cond
 Pointer to the condition variable the thread owning this THD is currently waiting for. More...
 
mysql_cond_t COND_thr_lock
 Condition variable used for waiting by the THR_LOCK.c subsystem. More...
 
uint32 unmasked_server_id
 
uint32 server_id
 
uint32 file_id
 
uint16 peer_port
 
struct timeval start_time
 
struct timeval user_time
 
ulonglong start_utime
 Query start time, expressed in microseconds. More...
 
thr_lock_type update_lock_default
 Type of lock to be used for all DML statements, except INSERT, in cases when lock is not specified explicitly. More...
 
thr_lock_type insert_lock_default
 Type of lock to be used for INSERT statement if lock is not specified explicitly. More...
 
uint in_sub_stmt
 
uint fill_status_recursion_level
 Used by fill_status() to avoid acquiring LOCK_status mutex twice when this function is called recursively (e.g. More...
 
uint fill_variables_recursion_level
 
rpl_event_coordinates binlog_next_event_pos
 
ucharbinlog_row_event_extra_data
 
struct THD_timer_infotimer
 Holds active timer object. More...
 
struct THD_timer_infotimer_cache
 After resetting(cancelling) timer, current timer object is cached with timer_cache timer to reuse. More...
 
Global_read_lock global_read_lock
 
Vioactive_vio = {nullptr}
 
Vioclone_vio = {nullptr}
 
Item_change_list change_list
 This is used to track transient changes to items during optimization of a prepared statement/stored procedure. More...
 
Query_arenastmt_arena
 
table_map table_map_for_update
 
bool arg_of_last_insert_id_function
 
ulonglong first_successful_insert_id_in_prev_stmt
 
ulonglong first_successful_insert_id_in_prev_stmt_for_binlog
 
ulonglong first_successful_insert_id_in_cur_stmt
 
bool stmt_depends_on_first_successful_insert_id_in_prev_stmt
 
Discrete_intervals_list auto_inc_intervals_in_cur_stmt_for_binlog
 
Discrete_intervals_list auto_inc_intervals_forced
 
ulonglong previous_found_rows
 Stores the result of the FOUND_ROWS() function. More...
 
ulonglong current_found_rows
 Dynamic, collected and set also in subqueries. More...
 
bool is_operating_gtid_table_implicitly
 
bool is_operating_substatement_implicitly
 
ha_rows num_truncated_fields
 
const CHARSET_INFOdb_charset
 
std::unique_ptr< PROFILINGprofiling
 
PSI_stage_progressm_stage_progress_psi
 Current stage progress instrumentation. More...
 
sql_digest_statem_digest
 Current statement digest. More...
 
unsigned char * m_token_array
 Current statement digest token array. More...
 
sql_digest_state m_digest_state
 Top level statement digest. More...
 
PSI_statement_lockerm_statement_psi
 Current statement instrumentation. More...
 
PSI_statement_locker_state m_statement_state
 Current statement instrumentation state. More...
 
PSI_transaction_lockerm_transaction_psi
 Current transaction instrumentation. More...
 
PSI_transaction_locker_state m_transaction_state
 Current transaction instrumentation state. More...
 
PSI_idle_lockerm_idle_psi
 Idle instrumentation. More...
 
PSI_idle_locker_state m_idle_state
 Idle instrumentation state. More...
 
bool m_server_idle
 True if the server code is IDLE for this connection. More...
 
query_id_t query_id
 
ulong statement_id_counter
 
ulong rand_saved_seed1
 
ulong rand_saved_seed2
 
my_thread_t real_id
 
uint tmp_table
 
uint server_status
 
uint open_options
 
enum enum_thread_type system_thread
 
enum_tx_isolation tx_isolation
 
bool tx_read_only
 
int tx_priority
 
int thd_tx_priority
 
enum_check_fields check_for_truncated_fields
 
Prealloced_array< Binlog_user_var_event *, 2 > user_var_events
 
MEM_ROOTuser_var_events_alloc
 
THDnext_to_commit
 Used by MYSQL_BIN_LOG to maintain the commit queue for binary log group commit. More...
 
bool binlog_need_explicit_defaults_ts
 The member is served for marking a query that CREATEs or ALTERs a table declared with a TIMESTAMP column as dependent on @session.explicit_defaults_for_timestamp. More...
 
enum THD::Commit_error commit_error
 
enum durability_properties durability_property
 
std::atomic< killed_statekilled
 
bool running_explain_analyze = false
 Whether we are currently in the execution phase of an EXPLAIN ANALYZE query. More...
 
dd::DD_kill_immunizerkill_immunizer
 When operation on DD tables is in progress then THD is set to kill immune mode. More...
 
char scramble [SCRAMBLE_LENGTH+1]
 
bool slave_thread
 
uchar password
 
bool transaction_rollback_request
 Set by a storage engine to request the entire transaction (that possibly spans multiple engines) to rollback. More...
 
bool is_fatal_sub_stmt_error
 true if we are in a sub-statement and the current error can not be safely recovered until we left the sub-statement mode. More...
 
bool query_start_usec_used
 
bool rand_used
 
bool time_zone_used
 
bool in_lock_tables
 
bool is_slave_error
 True if a slave error. More...
 
bool thread_specific_used
 is set if some thread specific value(s) used in a statement. More...
 
bool charset_is_system_charset
 is set if a statement accesses a temporary table created through CREATE TEMPORARY TABLE. More...
 
bool charset_is_collation_connection
 
bool charset_is_character_set_filesystem
 
bool enable_slow_log
 
bool derived_tables_processing
 
bool parsing_system_view
 
sp_rcontextsp_runtime_ctx
 Current SP-runtime context. More...
 
sp_cachesp_proc_cache
 
sp_cachesp_func_cache
 
uint query_name_consts
 number of name_const() substitutions, see sp_head.cc:subst_spvars() More...
 
union {
   bool   bool_value
 
   long   long_value
 
   ulong   ulong_value
 
   ulonglong   ulonglong_value
 
   double   double_value
 
sys_var_tmp
 
struct {
   bool   do_union
 
   bool   unioned_events
 
   bool   unioned_events_trans
 
   query_id_t   first_query_id
 
binlog_evt_union
 
Locked_tables_list locked_tables_list
 
partition_infowork_part_info
 
Plugin_array audit_class_plugins
 Array of active audit plugins which have been used by this THD. More...
 
Prealloced_array< unsigned long, 11 > audit_class_mask
 Array of bits indicating which audit classes have already been added to the list of audit plugins which are currently in use. More...
 
bool m_enable_plugins
 
bool m_audited
 
Gtid owned_gtid
 The GTID of the currently owned transaction. More...
 
mysql::gtid::Tsid owned_tsid
 For convenience, this contains the TSID component of the GTID stored in owned_gtid. More...
 
Se_GTID_flagset m_se_gtid_flags
 Flags for SE GTID persistence. More...
 
Rpl_thd_context rpl_thd_ctx
 
bool skip_gtid_rollback
 
bool is_commit_in_middle_of_statement
 
bool has_gtid_consistency_violation
 
thd_scheduler scheduler
 
Opt_trace_context opt_trace
 optimizer trace of current statement More...
 
Session_tracker session_tracker
 
Session_sysvar_resource_manager session_sysvar_res_mgr
 
bool duplicate_slave_id
 This is only used by master dump threads. More...
 
XID debug_binlog_xid_last
 
Transactional_ddl_context m_transactional_ddl {this}
 
bool m_inside_system_variable_global_update
 Flag to indicate this thread is executing sys_var::update for a OPT_GLOBAL variable. More...
 
PS_PARAMbind_parameter_values
 The parameter value bindings for the current query. More...
 
unsigned long bind_parameter_values_count
 the number of elements in parameters More...
 
mysql_mutex_t LOCK_group_replication_connection_mutex
 
mysql_cond_t COND_group_replication_connection_cond_var
 
const char * current_key_name
 
ulonglong conn_mem_alloc_number
 
bool is_mem_cnt_error_issued
 
bool in_loadable_function {false}
 
bool has_incremented_gtid_automatic_count
 Flag indicating whether this session incremented the number of sessions with GTID_NEXT set to AUTOMATIC:tag. More...
 
- Public Attributes inherited from Query_arena
MEM_ROOTmem_root
 
bool is_repreparing {false}
 To check whether a reprepare operation is active. More...
 
- Public Attributes inherited from Open_tables_state
TABLEopen_tables
 List of regular tables in use by this thread. More...
 
TABLEtemporary_tables
 List of temporary tables used by this thread. More...
 
MYSQL_LOCKlock
 
MYSQL_LOCKextra_lock
 
enum enum_locked_tables_mode locked_tables_mode
 
uint state_flags
 

Static Public Attributes

static const char *const DEFAULT_WHERE = "field list"
 
static const int OWNED_SIDNO_GTID_SET = -1
 
static const int OWNED_SIDNO_ANONYMOUS = -2
 

Private Types

enum  enum_thd_life_cycle_stages {
  ACTIVE = 0 , ACTIVE_AND_CLEAN , SCHEDULED_FOR_DISPOSAL , CLEANED_UP ,
  RESOURCES_RELEASED , DISPOSED
}
 Represents life cycle stages of THD instance. More...
 

Private Member Functions

bool is_stmt_prepare () const =delete
 
bool is_stmt_prepare_or_first_sp_execute () const =delete
 
bool is_stmt_prepare_or_first_stmt_execute () const =delete
 
bool is_regular () const =delete
 
const char * proc_info (const System_variables &sysvars) const
 Return the m_proc_info, possibly using the string of an older server release, according to @terminology_use_previous. More...
 
void start_disposal ()
 Set THD in ACTIVE life stage to disposal stage. More...
 
bool is_cleanup_done ()
 
void cleanup (void)
 
void init (void)
 
bool handle_condition (uint sql_errno, const char *sqlstate, Sql_condition::enum_severity_level *level, const char *msg)
 Handle a sql condition. More...
 
Sql_conditionraise_condition (uint sql_errno, const char *sqlstate, Sql_condition::enum_severity_level level, const char *msg, bool fatal_error=false)
 Raise a generic SQL condition. More...
 
void cleanup_after_parse_error ()
 Restore session state in case of parse error. More...
 
bool push_event_tracking_data (Event_tracking_class event, const Event_tracking_information *Event_tracking_information)
 
void pop_event_tracking_data ()
 

Private Attributes

std::unique_ptr< LEXmain_lex
 The lex to hold the parsed tree of conventional (non-prepared) queries. More...
 
std::unique_ptr< dd::cache::Dictionary_clientm_dd_client
 
LEX_CSTRING m_query_string
 The query associated with this statement. More...
 
String m_normalized_query
 
std::atomic< bool > m_safe_to_display
 
LEX_CSTRING m_catalog
 Currently selected catalog. More...
 
LEX_CSTRING m_db
 Name of the current (default) database. More...
 
resourcegroups::Resource_group_ctx m_resource_group_ctx
 Resource group context indicating the current resource group and the name of the resource group to switch to during execution of a query. More...
 
String m_rewritten_query
 In some cases, we may want to modify the query (i.e. More...
 
std::unique_ptr< Secondary_engine_statement_contextm_secondary_engine_statement_context
 Current query's secondary engine statement context. More...
 
mysql_mutex_t LOCK_query_plan
 Protects query plan (SELECT/UPDATE/DELETE's) from being freed/changed while another thread explains it. More...
 
std::atomic< bool > m_cached_is_connection_alive
 Keep a cached value saying whether the connection is alive. More...
 
Protocolm_protocol
 
SSL_handle m_SSL = {nullptr}
 SSL data attached to this connection. More...
 
PSI_stage_key m_current_stage_key
 
const char * m_proc_info
 
bool m_is_low_level_commit_ordering_enabled = false
 Flag indicating whether additional ordering in the ha_commit_low function is enabled. More...
 
enum enum_server_command m_command
 Type of current query: COM_STMT_PREPARE, COM_QUERY, etc. More...
 
bool m_is_admin_conn
 
ulonglong m_lock_usec
 Time spent waiting for TABLE locks and DATA locks. More...
 
Prealloced_array< Ha_data, PREALLOC_NUM_HAha_data
 
bool skip_readonly_check
 
bool skip_transaction_read_only_check
 
binlog_filter_state m_binlog_filter_state
 Indicate if the current statement should be discarded instead of written to the binlog. More...
 
enum_binlog_format current_stmt_binlog_format
 Indicates the format in which the current statement will be logged. More...
 
uint32 binlog_unsafe_warning_flags
 Bit field for the state of binlog warnings. More...
 
uint binlog_table_maps
 
List< char > * binlog_accessed_db_names
 
NET net
 
String packet
 
std::unique_ptr< Transaction_ctxm_transaction
 
Attachable_trxm_attachable_trx
 
longlong m_row_count_func
 Stores the result of ROW_COUNT() function. More...
 
ha_rows m_sent_row_count
 Number of rows we actually sent to the client, including "synthetic" rows in ROLLUP etc. More...
 
ha_rows m_examined_row_count
 Number of rows read and/or evaluated for a statement. More...
 
USER_CONNm_user_connect
 
my_thread_id m_thread_id
 This counter is 32 bit because of the client protocol. More...
 
bool m_is_fatal_error
 Set to true if execution of the current compound statement can not continue. More...
 
enum_thd_life_cycle_stages m_thd_life_cycle_stage
 
std::atomic< PSI_thread * > m_psi
 Performance schema thread instrumentation for this session. More...
 
Internal_error_handlerm_internal_handler
 The current internal error handler for this thread, or NULL. More...
 
MEM_ROOT main_mem_root
 This memory root is used for two purposes: More...
 
Diagnostics_area main_da
 
Diagnostics_area m_parser_da
 cf. More...
 
Diagnostics_area m_query_rewrite_plugin_da
 
Diagnostics_aream_query_rewrite_plugin_da_ptr
 
Diagnostics_aream_stmt_da
 
bool m_binlog_invoker
 It will be set TRUE if CURRENT_USER() is called in account management statements or default definer is set in CREATE/ALTER SP, SF, Event, TRIGGER or VIEW statements. More...
 
LEX_CSTRING m_invoker_user
 It points to the invoker in the Query_log_event. More...
 
LEX_CSTRING m_invoker_host
 
Cost_model_server m_cost_model
 Optimizer cost model for server operations. More...
 
Cost_model_server m_cost_model_hypergraph
 
bool is_a_srv_session_thd
 Variable to mark if the object is part of a Srv_session object, which aggregates THD. More...
 
const st_plugin_intm_plugin {nullptr}
 Stores the plugin id it is attached to (if any). More...
 
bool m_is_plugin_fake_ddl
 Creating or dropping plugin native table through a plugin service. More...
 
uint tmp_table_seq_id
 Sequential number of internal tmp table created in the statement. More...
 
bool waiting_for_disk_space = false
 
Secondary_engine_optimization m_secondary_engine_optimization
 This flag tells if a secondary storage engine can be used to execute a query in this session. More...
 
bool m_secondary_engine_forced {false}
 Flag that tells whether secondary storage engine is forced for execution. More...
 
std::atomic< bool > m_is_system_user
 Flag that indicates if the user of current session has SYSTEM_USER privilege. More...
 
std::atomic< bool > m_is_connection_admin
 Flag that indicates if the user of current session has CONNECTION_ADMIN privilege. More...
 
std::unordered_map< unsigned int, void * > external_store_
 
Event_reference_caching_cacheevents_cache_ {nullptr}
 
Event_tracking_data_stack event_tracking_data_
 
bool audit_plugins_present
 
const char * m_trans_log_file
 The binary log position of the transaction. More...
 
char * m_trans_fixed_log_file
 
my_off_t m_trans_end_pos
 

Friends

class Sql_cmd_common_signal
 
class Sql_cmd_signal
 
class Sql_cmd_resignal
 
class Protocol_classic
 
void push_warning (THD *thd, Sql_condition::enum_severity_level severity, uint code, const char *message_text)
 Push the warning to error list if there is still room in the list. More...
 
void my_message_sql (uint, const char *, myf)
 All global error messages are sent here where the first one is stored for the client. More...
 

Detailed Description

For each client connection we create a separate thread with THD serving as a thread/connection descriptor.

Member Typedef Documentation

◆ Se_GTID_flagset

using THD::Se_GTID_flagset = std::bitset<SE_GTID_MAX>

◆ sql_mode_t

using THD::sql_mode_t = uint64_t

Member Enumeration Documentation

◆ binlog_filter_state

Enumerator
BINLOG_FILTER_UNKNOWN 
BINLOG_FILTER_CLEAR 
BINLOG_FILTER_SET 

◆ Commit_error

Enumerator
CE_NONE 
CE_FLUSH_ERROR 
CE_FLUSH_GNO_EXHAUSTED_ERROR 
CE_SYNC_ERROR 
CE_COMMIT_ERROR 
CE_ERROR_COUNT 

◆ enum_binlog_query_type

Enumerator
ROW_QUERY_TYPE 
STMT_QUERY_TYPE 
QUERY_TYPE_COUNT 

◆ enum_reset_lex

Enumerator
RESET_LEX 
DO_NOT_RESET_LEX 

◆ enum_thd_life_cycle_stages

Represents life cycle stages of THD instance.

Stage transition in THD clean up:

  1. ACTIVE -> ACTIVE_AND_CLEAN

Stage transition in THD disposal:

  1. ACTIVE -> SCHEDULED_FOR_DISPOSAL -> CLEANED_UP -> RESOURCES_RELEASED -> DISPOSED.
  2. ACTIVE_AND_CLEAN -> CLEANED_UP -> RESOURCES_RELEASED -> DISPOSED.
Enumerator
ACTIVE 
ACTIVE_AND_CLEAN 
SCHEDULED_FOR_DISPOSAL 
CLEANED_UP 
RESOURCES_RELEASED 
DISPOSED 

◆ killed_state

Enumerator
NOT_KILLED 
KILL_CONNECTION 
KILL_QUERY 
KILL_TIMEOUT 
KILLED_NO_VALUE 

◆ Se_GTID_flag

enum THD::Se_GTID_flag : size_t

SE GTID persistence flag types.

Enumerator
SE_GTID_PIN 

Pin owned GTID.

SE_GTID_CLEANUP 

Cleanup GTID during unpin.

SE_GTID_PERSIST 

SE would persist GTID for current transaction.

SE_GTID_RESET_LOG 

If RESET log in progress.

SE_GTID_PERSIST_EXPLICIT 

Explicit request for SE to persist GTID for current transaction.

SE_GTID_MAX 

Max element holding the biset size.

Constructor & Destructor Documentation

◆ THD()

THD::THD ( bool  enable_plugins = true)
explicit

◆ ~THD()

THD::~THD ( )
override

Member Function Documentation

◆ add_external()

bool THD::add_external ( unsigned int  slot,
void *  data 
)

◆ alloc()

void * THD::alloc ( size_t  size)
inline

◆ awake()

void THD::awake ( THD::killed_state  state_to_set)

Awake a thread.

Parameters
[in]state_to_setvalue for THD::killed

This is normally called from another thread's THD object.

Note
Do always call this while holding LOCK_thd_data.

◆ backup_ha_data()

void THD::backup_ha_data ( Prealloced_array< Ha_data, PREALLOC_NUM_HA > *  backup)
inline

Copy ha_data into the provided argument.

Used by Attachble_transaction.

◆ begin_attachable_ro_transaction()

void THD::begin_attachable_ro_transaction ( )

Start a read-only attachable transaction.

There must be no active attachable transactions (in other words, there can be only one active attachable transaction at a time).

◆ begin_attachable_rw_transaction()

void THD::begin_attachable_rw_transaction ( )

Start a read-write attachable transaction.

All the read-only class' requirements apply. Additional requirements are documented along the class declaration.

◆ binlog_flush_pending_rows_event()

int THD::binlog_flush_pending_rows_event ( bool  stmt_end)
inline

◆ binlog_invoker()

void THD::binlog_invoker ( )
inline

◆ catalog()

const LEX_CSTRING & THD::catalog ( ) const
inline

◆ change_item_tree()

void THD::change_item_tree ( Item **  place,
Item new_value 
)
inline

Record a transient change to a pointer to an Item within another Item.

◆ charset() [1/2]

const CHARSET_INFO * THD::charset ( ) const
inline

◆ charset() [2/2]

const CHARSET_INFO * THD::charset ( ) const
inline

◆ check_clone_vio()

bool THD::check_clone_vio ( )
inline

Check if clone network Vio is active.

◆ check_event_subscribers()

bool THD::check_event_subscribers ( Event_tracking_class  event,
unsigned long  subevent,
bool  check_audited 
)

◆ claim_memory_ownership()

void THD::claim_memory_ownership ( bool  claim)

Claim all the memory used by the THD object.

This method is to keep memory instrumentation statistics updated, when an object is transferred across threads.

◆ cleanup()

void THD::cleanup ( void  )
private

◆ cleanup_after_parse_error()

void THD::cleanup_after_parse_error ( )
private

Restore session state in case of parse error.

This is a clean up function that is invoked after the Bison generated parser before returning an error from THD::sql_parser(). If your semantic actions manipulate with the session state (which is a very bad practice and should not normally be employed) and need a clean-up in case of error, and you can not use destructor rule in the grammar file itself, this function should be used to implement the clean up.

◆ cleanup_after_query()

void THD::cleanup_after_query ( )

◆ cleanup_connection()

void THD::cleanup_connection ( void  )

◆ clear_active_vio()

void THD::clear_active_vio ( )
inline

◆ clear_binlog_local_stmt_filter()

void THD::clear_binlog_local_stmt_filter ( )
inline

◆ clear_binlog_table_maps()

void THD::clear_binlog_table_maps ( )
inline

◆ clear_clone_vio()

void THD::clear_clone_vio ( )
inline

Clear clone network Vio for remote clone.

◆ clear_copy_status_var()

void THD::clear_copy_status_var ( )
inline

Clear copy of the status variables.

◆ clear_current_query_costs()

void THD::clear_current_query_costs ( )
inline

Clear the query costs attributes for the current query.

◆ clear_current_stmt_binlog_format_row()

void THD::clear_current_stmt_binlog_format_row ( )
inline

◆ clear_error()

void THD::clear_error ( )
inline

Clear the current error, if any.

We do not clear is_fatal_error or is_fatal_sub_stmt_error since we assume this is never called if the fatal error is set.

◆ clear_log_reset()

void THD::clear_log_reset ( )
inline

Cleared after flushing SE logs during binlog reset.

◆ clear_next_event_pos()

void THD::clear_next_event_pos ( )

◆ clear_owned_gtids()

void THD::clear_owned_gtids ( )
inline

◆ collation()

const CHARSET_INFO * THD::collation ( )
inline

◆ convert_string() [1/2]

bool THD::convert_string ( LEX_STRING to,
const CHARSET_INFO to_cs,
const char *  from,
size_t  from_length,
const CHARSET_INFO from_cs,
bool  report_error = false 
)
inline

◆ convert_string() [2/2]

bool THD::convert_string ( LEX_STRING to,
const CHARSET_INFO to_cs,
const char *  from,
size_t  from_length,
const CHARSET_INFO from_cs,
bool  report_error = false 
)

◆ copy_db_to() [1/2]

bool THD::copy_db_to ( char **  p_db,
size_t *  p_db_length 
) const
inline

◆ copy_db_to() [2/2]

bool THD::copy_db_to ( char const **  p_db,
size_t *  p_db_length 
) const
inline

◆ copy_status_var()

void THD::copy_status_var ( System_status_var dst_var)
inline

Copy status variables into a structure pointed by the specified pointer and keep track of the pointer internally.

Parameters
dst_varstatus variable structure pointer, where internal status variables are copied into.

◆ copy_table_access_properties()

void THD::copy_table_access_properties ( THD thd)

Copy session properties that affect table access from the parent session to the current session.

The following properties:

  • the OPTION_BIN_LOG flag,
  • the skip_readonly_check flag,
  • the transaction isolation (tx_isolation) are copied from the parent to the current THD.

This is useful to execute an isolated, internal THD session to access tables, while leaving tables in the parent session unchanged.

Parameters
thdparent session

◆ cost_model()

const Cost_model_server * THD::cost_model ( ) const

Retrieve the optimizer cost model for this connection.

◆ db()

const LEX_CSTRING & THD::db ( ) const
inline

◆ dd_client()

dd::cache::Dictionary_client * THD::dd_client ( ) const
inline

◆ debug_assert_query_locked()

void THD::debug_assert_query_locked ( ) const

For safe and protected access to the query string, the following rules should be followed: 1: Only the owner (current_thd) can set the query string.

This will be protected by LOCK_thd_query. 2: The owner (current_thd) can read the query string without locking LOCK_thd_query. 3: Other threads must lock LOCK_thd_query before reading the query string.

This means that write-write conflicts are avoided by LOCK_thd_query. Read(by owner or other thread)-write(other thread) are disallowed. Read(other thread)-write(by owner) conflicts are avoided by LOCK_thd_query. Read(by owner)-write(by owner) won't happen as THD=thread.

We want to keep current_thd out of header files, so the debug assert, is moved to the .cc file. In optimized mode, we want this getter to be fast, so we inline it.

◆ decrement_user_connections_counter()

void THD::decrement_user_connections_counter ( )

◆ disable_low_level_commit_ordering()

void THD::disable_low_level_commit_ordering ( )

Enables ordering in ha_commit_low.

Used in binlog::commit

Note
Additional requirements need to be met in order to invoke commit ordering in ha_commit_low
See also
is_ha_commit_low_invoking_commit_order

◆ disable_mem_cnt()

void THD::disable_mem_cnt ( )
inline

◆ disconnect()

void THD::disconnect ( bool  server_shutdown = false)

Disconnect the associated communication endpoint.

Close the Vio associated this session.

Remarks
LOCK_thd_data is taken due to the fact that the Vio might be disassociated concurrently.

◆ enable_low_level_commit_ordering()

void THD::enable_low_level_commit_ordering ( )

Enables ordering in ha_commit_low.

Used in binlog::commit

Note
Additional requirements need to be met in order to invoke commit ordering in ha_commit_low
See also
is_ha_commit_low_invoking_commit_order

◆ enable_mem_cnt()

void THD::enable_mem_cnt ( )
inline

◆ end_attachable_transaction()

void THD::end_attachable_transaction ( )

End an active attachable transaction.

Applies to both the read-only and the read-write versions. Note, that the read-write attachable transaction won't be terminated inside this method. To invoke the function there must be active attachable transaction.

◆ end_statement()

void THD::end_statement ( )

◆ enter_cond()

void THD::enter_cond ( mysql_cond_t cond,
mysql_mutex_t mutex,
const PSI_stage_info stage,
PSI_stage_info old_stage,
const char *  src_function,
const char *  src_file,
int  src_line 
)
inlineoverridevirtual

Enter a condition wait.

For enter_cond() / exit_cond() to work the mutex must be held before enter_cond(); this mutex must then be released before exit_cond(). Usage must be: lock mutex; enter_cond(); your code; unlock mutex; exit_cond().

Parameters
condthe condition to wait on
mutexthe associated mutex
[in]stagethe stage to enter, or NULL
[out]old_stagethe previous stage, or NULL
src_functionfunction name of the caller
src_filefile name of the caller
src_lineline number of the caller
See also
ENTER_COND(), THD::enter_cond()
EXIT_COND(), THD::exit_cond()

Implements MDL_context_owner.

◆ enter_locked_tables_mode()

void THD::enter_locked_tables_mode ( enum_locked_tables_mode  mode_arg)
inline

◆ enter_stage()

void THD::enter_stage ( const PSI_stage_info stage,
PSI_stage_info old_stage,
const char *  calling_func,
const char *  calling_file,
const unsigned int  calling_line 
)

◆ event_notify()

bool THD::event_notify ( struct st_mysql_event_generic event_data)

◆ exit_cond()

void THD::exit_cond ( const PSI_stage_info stage,
const char *  src_function,
const char *  src_file,
int  src_line 
)
inlineoverridevirtual

End a wait on a condition.

Parameters
[in]stagethe new stage to enter
src_functionfunction name of the caller
src_filefile name of the caller
src_lineline number of the caller
See also
ENTER_COND(), THD::enter_cond()
EXIT_COND(), THD::exit_cond()

Implements MDL_context_owner.

◆ fatal_error()

void THD::fatal_error ( )
inline

Mark the current error as fatal.

Warning: this does not set any error, it sets a property of the error, so must be followed or prefixed with my_error().

◆ fetch_external()

void * THD::fetch_external ( unsigned int  slot)

◆ fill_information_schema_tables()

bool THD::fill_information_schema_tables ( ) const
inline

◆ force_one_auto_inc_interval()

void THD::force_one_auto_inc_interval ( ulonglong  next_id)
inline

◆ found_rows()

ulonglong THD::found_rows ( ) const
inline

◆ get_binlog_accessed_db_names()

List< char > * THD::get_binlog_accessed_db_names ( ) const
inline

◆ get_binlog_local_stmt_filter()

binlog_filter_state THD::get_binlog_local_stmt_filter ( ) const
inline

◆ get_binlog_table_maps()

uint THD::get_binlog_table_maps ( ) const
inline

◆ get_command()

enum enum_server_command THD::get_command ( ) const
inline

◆ get_current_stage_key()

PSI_stage_key THD::get_current_stage_key ( ) const
inline

◆ get_definer()

void THD::get_definer ( LEX_USER definer)

◆ get_event_tracking_data()

Event_tracking_data THD::get_event_tracking_data ( )
inline

◆ get_examined_row_count()

ha_rows THD::get_examined_row_count ( ) const
inline

◆ get_gtid_next_list()

Gtid_set * THD::get_gtid_next_list ( )
inline

Return the value of @gtid_next_list: either a Gtid_set or NULL.

◆ get_gtid_next_list_const()

const Gtid_set * THD::get_gtid_next_list_const ( ) const
inline

Return the value of @gtid_next_list: either a Gtid_set or NULL.

◆ get_ha_data()

Ha_data * THD::get_ha_data ( int  slot)
inline

Retrieve Ha_data for a given slot.

Each handler has a fixed slot nr.

◆ get_internal_handler()

const Internal_error_handler * THD::get_internal_handler ( ) const
inline

◆ get_invoker_host()

LEX_CSTRING THD::get_invoker_host ( ) const
inline

◆ get_invoker_user()

LEX_CSTRING THD::get_invoker_user ( ) const
inline

◆ get_lock_usec()

ulonglong THD::get_lock_usec ( )
inline

◆ get_net()

const NET * THD::get_net ( ) const
inline

◆ get_parser_da()

Diagnostics_area * THD::get_parser_da ( )
inline

Returns thread-local Diagnostics Area for parsing.

We need to have a clean DA in case errors or warnings are thrown during parsing, but we can't just reset the main DA in case we have a diagnostic statement on our hand that needs the old DA to answer questions about the previous execution. Keeping a static per-thread DA for parsing is less costly than allocating a temporary one for each statement we parse.

◆ get_plugin()

const st_plugin_int * THD::get_plugin ( ) const
inline

Returns the plugin, the thd belongs to.

Returns
pointer to the plugin id

◆ get_protocol() [1/2]

Protocol * THD::get_protocol ( )

◆ get_protocol() [2/2]

const Protocol * THD::get_protocol ( ) const
inline

◆ get_protocol_classic() [1/2]

Protocol_classic * THD::get_protocol_classic ( )

◆ get_protocol_classic() [2/2]

const Protocol_classic * THD::get_protocol_classic ( ) const
inline

Asserts that the protocol is of type text or binary and then returns the m_protocol casted to Protocol_classic.

This method is needed to prevent misuse of pluggable protocols by legacy code

◆ get_psi()

PSI_thread * THD::get_psi ( ) const
inline

Read the performance schema thread instrumentation associated with this user session.

This method is safe to use from a different thread.

◆ get_query_rewrite_plugin_da()

Diagnostics_area * THD::get_query_rewrite_plugin_da ( )
inline

Returns thread-local Diagnostics Area to be used by query rewrite plugins.

Query rewrite plugins use their own diagnostics area. The reason is that they are invoked right before and right after parsing, and we don't want conditions raised by plugins in either statement nor parser DA until we know which type of statement we have parsed.

Note
The diagnostics area is instantiated the first time it is asked for.

◆ get_rand_seed()

uint THD::get_rand_seed ( ) const
inlineoverridevirtual

Provide thread specific random seed for MDL_context's PRNG.

Note that even if two connections will request seed during handling of statements which were started at exactly the same time, and thus will get the same values in PRNG at the start, they will naturally diverge soon, since calls to PRNG in MDL subsystem are affected by many factors making process quite random. OTOH the fact that we use time as a seed gives more randomness and thus better coverage in tests as opposed to using thread_id for the same purpose.

Implements MDL_context_owner.

◆ get_row_count_func()

longlong THD::get_row_count_func ( ) const
inline

◆ get_sent_row_count()

ha_rows THD::get_sent_row_count ( ) const
inline

◆ get_ssl()

SSL_handle THD::get_ssl ( ) const
inline

◆ get_stacked_da()

const Diagnostics_area * THD::get_stacked_da ( ) const
inline

Returns the second Diagnostics Area for the current statement.

◆ get_stmt_da() [1/2]

Diagnostics_area * THD::get_stmt_da ( )
inline

Returns first Diagnostics Area for the current statement.

◆ get_stmt_da() [2/2]

const Diagnostics_area * THD::get_stmt_da ( ) const
inline

Returns first Diagnostics Area for the current statement.

◆ get_thd()

THD * THD::get_thd ( )
inlineoverridevirtual

Within MDL subsystem this one is only used for DEBUG_SYNC.

Do not use it to peek/poke into other parts of THD from MDL. However it is OK to use this method in callbacks provided by SQL-layer to MDL subsystem (since SQL-layer has full access to THD anyway).

Warning
For some derived classes implementation of this method can return nullptr. Calling side must be ready to handle this case.

Implements MDL_context_owner.

◆ get_tmp_table_seq_id()

uint THD::get_tmp_table_seq_id ( )
inline

◆ get_trans_fixed_pos()

void THD::get_trans_fixed_pos ( const char **  file_var,
my_off_t pos_var 
) const
inline

◆ get_trans_pos()

void THD::get_trans_pos ( const char **  file_var,
my_off_t pos_var 
) const
inline

◆ get_transaction() [1/2]

Transaction_ctx * THD::get_transaction ( )
inline

◆ get_transaction() [2/2]

const Transaction_ctx * THD::get_transaction ( ) const
inline

◆ get_user_connect()

const USER_CONN * THD::get_user_connect ( ) const
inline

◆ get_vio_type()

enum_vio_type THD::get_vio_type ( ) const

◆ handle_condition()

bool THD::handle_condition ( uint  sql_errno,
const char *  sqlstate,
Sql_condition::enum_severity_level level,
const char *  msg 
)
private

Handle a sql condition.

Parameters
sql_errnothe condition error number
sqlstatethe condition sqlstate
levelthe condition level
msgthe condition message text
Returns
true if the condition is handled

◆ has_invoker()

bool THD::has_invoker ( ) const
inline

◆ in_active_multi_stmt_transaction()

bool THD::in_active_multi_stmt_transaction ( ) const
inline

true if the session is in a multi-statement transaction mode (

See also
in_multi_stmt_transaction_mode()) and there is an active transaction, i.e. there is an explicit start of a transaction with BEGIN statement, or implicit with a statement that uses a transactional engine.

For example, these scenarios don't start an active transaction (even though the server is in multi-statement transaction mode):

set @@autocommit=0;
select * from nontrans_table;
set @var = true;
flush tables;

Note, that even for a statement that starts a multi-statement transaction (i.e. select * from trans_table), this flag won't be set until we open the statement's tables and the engines register themselves for the transaction (see trans_register_ha()), hence this method is reliable to use only after open_tables() has completed.

Why do we need a flag?

We need to maintain a (at first glance redundant) session flag, rather than looking at thd->transaction.all.ha_list because of explicit start of a transaction with BEGIN.

I.e. in case of BEGIN; select * from nontrans_t1; <– in_active_multi_stmt_transaction() is true

◆ in_multi_stmt_transaction_mode()

bool THD::in_multi_stmt_transaction_mode ( ) const
inline

Returns true if session is in a multi-statement transaction mode.

OPTION_NOT_AUTOCOMMIT: When autocommit is off, a multi-statement transaction is implicitly started on the first statement after a previous transaction has been ended.

OPTION_BEGIN: Regardless of the autocommit status, a multi-statement transaction can be explicitly started with the statements "START TRANSACTION", "BEGIN [WORK]", "[COMMIT | ROLLBACK] AND CHAIN", etc.

Note: this doesn't tell you whether a transaction is active. A session can be in multi-statement transaction mode, and yet have no active transaction, e.g., in case of: set @@autocommit=0; set @a= 3; <– these statements don't set transaction isolation level serializable; <– start an active flush tables; <– transaction

I.e. for the above scenario this function returns true, even though no active transaction has begun.

See also
in_active_multi_stmt_transaction()

◆ inc_examined_row_count()

void THD::inc_examined_row_count ( ha_rows  count)

◆ inc_lock_usec()

void THD::inc_lock_usec ( ulonglong  usec)

◆ inc_sent_row_count()

void THD::inc_sent_row_count ( ha_rows  count)

◆ inc_status_created_tmp_disk_tables()

void THD::inc_status_created_tmp_disk_tables ( )

◆ inc_status_created_tmp_tables()

void THD::inc_status_created_tmp_tables ( )

◆ inc_status_select_full_join()

void THD::inc_status_select_full_join ( )

◆ inc_status_select_full_range_join()

void THD::inc_status_select_full_range_join ( )

◆ inc_status_select_range()

void THD::inc_status_select_range ( )

◆ inc_status_select_range_check()

void THD::inc_status_select_range_check ( )

◆ inc_status_select_scan()

void THD::inc_status_select_scan ( )

◆ inc_status_sort_merge_passes()

void THD::inc_status_sort_merge_passes ( )

◆ inc_status_sort_range()

void THD::inc_status_sort_range ( )

◆ inc_status_sort_rows()

void THD::inc_status_sort_rows ( ha_rows  count)

◆ inc_status_sort_scan()

void THD::inc_status_sort_scan ( )

◆ increment_con_per_hour_counter()

void THD::increment_con_per_hour_counter ( )

◆ increment_questions_counter()

void THD::increment_questions_counter ( )

◆ increment_updates_counter()

void THD::increment_updates_counter ( )

◆ increment_user_connections_counter()

void THD::increment_user_connections_counter ( )

◆ init()

void THD::init ( void  )
private

◆ init_cost_model()

void THD::init_cost_model ( )

Initialize the optimizer cost model.

This function should be called each time a new query is started.

◆ init_query_mem_roots()

void THD::init_query_mem_roots ( )

Initialize memory roots necessary for query processing and (!) pre-allocate memory for it.

We can't do that in THD constructor because there are use cases (acl_init, watcher threads, killing mysqld) where it's vital to not allocate excessive and not used memory. Note, that we still don't return error from init_query_mem_roots() if preallocation fails, we should notice that at the first call to alloc_root.

◆ is_a_srv_session()

bool THD::is_a_srv_session ( ) const
inline

◆ is_admin_connection()

bool THD::is_admin_connection ( ) const
inline

◆ is_applier_thread()

bool THD::is_applier_thread ( ) const
inline

◆ is_attachable_ro_transaction_active()

bool THD::is_attachable_ro_transaction_active ( ) const
inline
Returns
true if there is an active attachable transaction.

◆ is_attachable_rw_transaction_active()

bool THD::is_attachable_rw_transaction_active ( ) const
inline
Returns
true if there is an active rw attachable transaction.

◆ is_attachable_transaction_active()

bool THD::is_attachable_transaction_active ( ) const
inline
Returns
true if there is an active attachable transaction.

◆ is_being_disposed()

bool THD::is_being_disposed ( ) const

Check if THD is being disposed (i.e.

m_thd_life_cycle_stage >= SCHEDULED_FOR_DISPOSAL)

Non-owner thread should acquire LOCK_thd_data to check THD state without getting into races.

Returns
true of THD is being disposed.

◆ is_binlog_applier()

bool THD::is_binlog_applier ( ) const
inline

The function checks whether the thread is processing queries from binlog, as automatically generated by mysqlbinlog.

Returns
true when the thread is a binlog applier

◆ is_bootstrap_system_thread()

bool THD::is_bootstrap_system_thread ( ) const
inline

◆ is_classic_protocol()

bool THD::is_classic_protocol ( ) const

◆ is_cleanup_done()

bool THD::is_cleanup_done ( )
private
Returns
true if THD is cleaned up.

◆ is_cmd_skip_readonly()

bool THD::is_cmd_skip_readonly ( ) const
inline

◆ is_cmd_skip_transaction_read_only()

bool THD::is_cmd_skip_transaction_read_only ( ) const
inline

◆ is_connected()

bool THD::is_connected ( bool  use_cached_connection_alive = false)
finalvirtual

Return false if connection to client is broken.

Implements MDL_context_owner.

◆ is_connection_admin()

bool THD::is_connection_admin ( )
inline

Returns if the user of the session has the CONNECTION_ADMIN privilege or not.

Return values
trueUser has CONNECTION_ADMIN privilege
falseOtherwise

◆ is_current_stmt_binlog_disabled()

bool THD::is_current_stmt_binlog_disabled ( ) const

Determine if binlogging is currently disabled for this session.

There are two ways that binlogging can be disabled:

  1. The binary log file is closed (globally). This can happen for two reasons: either –skip-log-bin was used on the command line, or a binlog write error happened when binlog_error_action=IGNORE_ERROR.
  2. The binary log is disabled on session level. This can happen for two reasons: either the user has set @session.sql_log_bin = 0, or the server code has internally disabled the binary log (by either setting thd->variables.option_bits &= ~OPTION_BIN_LOG or creating a Disable_binlog_guard object).

Even if this function returns true and the binary log is disabled, it is possible that the statement will be written to the binary log, in the cases where the server has merely temporarily disabled binary logging.

And even if this function returns false and the binary log is enabled, it is possible that the statement will not be written to the binary log, e.g. in case it is a no-op, it fails, it gets rolled back, or some other session closes the binary log due to a write error when using binlog_error_action=IGNORE_ERROR.

Return values
trueThe binary log is currently disabled for the statement.
falseThe binary log is currently enabled for the statement.

◆ is_current_stmt_binlog_enabled_and_caches_empty()

bool THD::is_current_stmt_binlog_enabled_and_caches_empty ( ) const

Checks whether binlog caches are disabled (binlog does not cache data) or empty in case binloggging is enabled in the current call to this function.

This function may be safely called in case binlogging is disabled.

Return values
truebinlog local caches are empty or disabled and binlogging is enabled
falsebinlog local caches are enabled and contain data or binlogging is disabled

◆ is_current_stmt_binlog_format_row()

int THD::is_current_stmt_binlog_format_row ( ) const
inline

Determine the binlog format of the current statement.

Return values
0if the current statement will be logged in statement format.
nonzeroif the current statement will be logged in row format.

◆ is_current_stmt_binlog_log_replica_updates_disabled()

bool THD::is_current_stmt_binlog_log_replica_updates_disabled ( ) const

Determine if binlogging is currently disabled for this session.

If the binary log is disabled for this thread (either by log_bin=0 or sql_log_bin=0 or by log_replica_updates=0 for a slave thread), then the statement will not be written to the binary log.

Return values
trueThe binary log is currently disabled for the statement.
falseThe binary log is currently enabled for the statement.

◆ is_current_stmt_binlog_row_enabled_with_write_set_extraction()

bool THD::is_current_stmt_binlog_row_enabled_with_write_set_extraction ( ) const

Determine if binloging is enabled in row format and write set extraction is enabled for this session.

Return values
trueif is enable
falseotherwise

◆ is_dd_system_thread()

bool THD::is_dd_system_thread ( ) const
inline

◆ is_engine_ha_data_detached()

bool THD::is_engine_ha_data_detached ( ) const
Returns
true when the current binlog (rli_fake) or slave (rli_slave) applier thread has detached the engine ha_data, see rpl_detach_engine_ha_data.
Note
The detached transaction applier resets a memo mark at once with this check.

◆ is_error()

bool THD::is_error ( ) const
inline

true if there is an error in the error stack.

Please use this method instead of direct access to net.report_error.

If true, the current (sub)-statement should be aborted. The main difference between this member and is_fatal_error is that a fatal error can not be handled by a stored procedure continue handler, whereas a normal error can.

To raise this flag, use my_error().

◆ is_extrenal_xa()

bool THD::is_extrenal_xa ( ) const
inline
Returns
true, if external XA transaction is in progress.

◆ is_fatal_error()

bool THD::is_fatal_error ( ) const
inline

◆ is_fsp_truncate_mode()

bool THD::is_fsp_truncate_mode ( ) const
inline

◆ is_init_file_system_thread()

bool THD::is_init_file_system_thread ( ) const
inline

◆ is_initialize_system_thread()

bool THD::is_initialize_system_thread ( ) const
inline

◆ is_killed()

int THD::is_killed ( ) const
inlinefinalvirtual

Has the owner thread been killed?

Implements MDL_context_owner.

◆ is_log_reset()

bool THD::is_log_reset ( ) const
inline
Returns
true, if binlog reset operation.

◆ is_low_level_commit_ordering_enabled()

bool THD::is_low_level_commit_ordering_enabled ( ) const

Obtains flag indicating whether additional ordering in the ha_commit_low function is enabled.

If not, ordering will take place in binlog::commit

Accessor for the m_is_low_level_commit_ordering_enabled

Returns
When true, ha_commit_low may order this transaction

◆ is_mem_cnt_error()

bool THD::is_mem_cnt_error ( )
inline

◆ is_one_phase_commit()

bool THD::is_one_phase_commit ( )
Returns
true, if single phase XA commit operation.

◆ is_plugin_fake_ddl()

bool THD::is_plugin_fake_ddl ( ) const
inline

◆ is_regular()

bool THD::is_regular ( ) const
inlineprivatedelete

◆ is_secondary_engine_forced()

bool THD::is_secondary_engine_forced ( ) const
inline

◆ is_secondary_storage_engine_eligible()

bool THD::is_secondary_storage_engine_eligible ( ) const

Checks if queries in this session can use a secondary storage engine for execution.

Returns
true if secondary storage engines can be used in this session, or false otherwise

◆ is_server_upgrade_thread()

bool THD::is_server_upgrade_thread ( ) const
inline

◆ is_stmt_prepare()

bool THD::is_stmt_prepare ( ) const
privatedelete

◆ is_stmt_prepare_or_first_sp_execute()

bool THD::is_stmt_prepare_or_first_sp_execute ( ) const
privatedelete

◆ is_stmt_prepare_or_first_stmt_execute()

bool THD::is_stmt_prepare_or_first_stmt_execute ( ) const
privatedelete

◆ is_strict_mode()

bool THD::is_strict_mode ( ) const
inline

◆ is_system_thread()

bool THD::is_system_thread ( ) const
inline

◆ is_system_user()

bool THD::is_system_user ( )
inline

Returns if the user of the session has the SYSTEM_USER privilege or not.

Return values
trueUser has SYSTEM_USER privilege
falseOtherwise

◆ is_waiting_for_disk_space()

bool THD::is_waiting_for_disk_space ( ) const
inline

Returns the current waiting_for_disk_space flag value.

◆ leave_locked_tables_mode()

void THD::leave_locked_tables_mode ( )

Leave explicit LOCK TABLES or prelocked mode and restore value of transaction sentinel in MDL subsystem.

◆ lock_query_plan()

void THD::lock_query_plan ( )
inline

Locks the query plan of this THD.

◆ mark_as_srv_session()

void THD::mark_as_srv_session ( )
inline

◆ mark_plugin_fake_ddl()

void THD::mark_plugin_fake_ddl ( bool  flag)
inline

◆ mark_transaction_to_rollback()

void THD::mark_transaction_to_rollback ( bool  all)

Mark transaction to rollback and mark error as fatal to a sub-statement.

Parameters
alltrue <=> rollback main transaction.

◆ might_have_commit_order_waiters()

bool THD::might_have_commit_order_waiters ( ) const
inlinefinalvirtual

Indicates that owner thread might have some commit order (non-MDL) waits for it which are still taken into account by MDL deadlock detection, even in cases when it doesn't have any MDL locks acquired and therefore can't have any MDL waiters.

Note
It is important for this check to be non-racy and quick (perhaps at expense of being pretty pessimistic), so it can be used to make decisions reliably about whether we can skip deadlock detection in some cases.

Implements MDL_context_owner.

◆ need_binlog_invoker()

bool THD::need_binlog_invoker ( ) const
inline

◆ nocheck_register_item_tree_change()

void THD::nocheck_register_item_tree_change ( Item **  place,
Item new_value 
)

Remember that place was updated with new_value so it can be restored by rollback_item_tree_changes().

Parameters
[in]placethe location that will change, and whose old value we need to remember for restoration
[in]new_valuenew value about to be inserted into *place

◆ normalized_query()

const String THD::normalized_query ( )

The current query in normalized form.

The format is intended to be identical to the digest text of performance_schema, but not limited in size. In this case the parse tree is traversed as opposed to a (limited) token buffer. The string is allocated by this Statement and will be available until the next call to this function or this object is deleted.

Note
We have no protection against out-of-memory errors as this function relies on the Item::print() interface which does not propagate errors.
Returns
The current query in normalized form.

◆ notify_hton_post_release_exclusive()

void THD::notify_hton_post_release_exclusive ( const MDL_key mdl_key)
overridevirtual

Notify interested storage engines that we have just released exclusive lock for the key.

Implements MDL_context_owner.

◆ notify_hton_pre_acquire_exclusive()

bool THD::notify_hton_pre_acquire_exclusive ( const MDL_key mdl_key,
bool *  victimized 
)
overridevirtual

Notify/get permission from interested storage engines before acquiring exclusive lock for the key.

The returned argument 'victimized' specify reason for lock not granted. If 'true', lock was refused in an attempt to resolve a possible MDL->GSL deadlock. Locking may then be retried.

Returns
False if notification was successful and it is OK to acquire lock, True if one of SEs asks to abort lock acquisition.

Implements MDL_context_owner.

◆ notify_shared_lock()

void THD::notify_shared_lock ( MDL_context_owner ctx_in_use,
bool  needs_thr_lock_abort 
)
overridevirtual

A callback to the server internals that is used to address special cases of the locking protocol.

Invoked when acquiring an exclusive lock, for each thread that has a conflicting shared metadata lock.

This function aborts waiting of the thread on a data lock, to make it notice the pending exclusive lock and back off.

Note
This function does not wait for the thread to give away its locks. Waiting is done outside for all threads at once.
Parameters
ctx_in_useThe MDL context owner (thread) to wake up.
needs_thr_lock_abortIndicates that to wake up thread this call needs to abort its waiting on table-level lock.

Implements MDL_context_owner.

◆ optimizer_switch_flag()

bool THD::optimizer_switch_flag ( ulonglong  flag) const
inline

Tells whether the given optimizer_switch flag is on.

◆ owned_gtid_is_empty()

bool THD::owned_gtid_is_empty ( )
inline
Returns
true, if owned GTID is empty or waiting for deferred cleanup.

◆ pin_gtid()

void THD::pin_gtid ( )
inline

Defer freeing owned GTID and TSID till unpinned.

◆ pop_diagnostics_area()

void THD::pop_diagnostics_area ( )
inline

Pop the top DA off the Diagnostics Area stack.

◆ pop_event_tracking_data()

void THD::pop_event_tracking_data ( )
private

◆ pop_internal_handler()

Internal_error_handler * THD::pop_internal_handler ( )

Remove the error handler last pushed.

◆ pop_lock_usec()

void THD::pop_lock_usec ( ulonglong  top)
inline

◆ pop_protocol()

void THD::pop_protocol ( )

Pops the top protocol of the Protocol stack and sets the previous one as the current protocol.

◆ proc_info() [1/2]

const char * THD::proc_info ( ) const
inline

◆ proc_info() [2/2]

const char * THD::proc_info ( const System_variables sysvars) const
private

Return the m_proc_info, possibly using the string of an older server release, according to @terminology_use_previous.

Parameters
sysvarsUse the value of @terminology_use_previous stored in this System_variables object.
Returns
The "proc_info", also known as "stage", of this thread.

◆ proc_info_session()

const char * THD::proc_info_session ( THD invoking_thd) const
inline

Return the m_proc_info, possibly using the string of an older server release, according to @session.terminology_use_previous.

Parameters
invoking_thdUse @session.terminology_use_previous of this session.
Returns
The "proc_info", also known as "stage", of this thread.

◆ push_diagnostics_area()

void THD::push_diagnostics_area ( Diagnostics_area da,
bool  copy_conditions = true 
)
inline

Push the given Diagnostics Area on top of the stack, making it the new first Diagnostics Area.

Conditions in the new second Diagnostics Area will be copied to the new first Diagnostics Area.

Parameters
daDiagnostics Area to be come the top of the Diagnostics Area stack.
copy_conditionsCopy the conditions from the new second Diagnostics Area to the new first Diagnostics Area, as per SQL standard.

◆ push_event_tracking_data()

bool THD::push_event_tracking_data ( Event_tracking_class  event,
const Event_tracking_information Event_tracking_information 
)
private

◆ push_internal_handler()

void THD::push_internal_handler ( Internal_error_handler handler)

Add an internal error handler to the thread execution context.

Parameters
handlerthe exception handler to add

◆ push_lock_usec()

void THD::push_lock_usec ( ulonglong top)
inline

◆ push_protocol() [1/2]

template<typename ProtocolClass >
void THD::push_protocol ( const std::unique_ptr< ProtocolClass > &  protocol)
inline

◆ push_protocol() [2/2]

void THD::push_protocol ( Protocol protocol)

Inserts the new protocol at the top of the protocol stack, and make it the current protocol for this thd.

Parameters
protocolProtocol to be inserted.

◆ query()

const LEX_CSTRING & THD::query ( ) const
inline

◆ query_start_in_secs()

time_t THD::query_start_in_secs ( ) const
inline

◆ query_start_timeval_trunc()

my_timeval THD::query_start_timeval_trunc ( uint  decimals)

◆ raise_condition()

Sql_condition * THD::raise_condition ( uint  sql_errno,
const char *  sqlstate,
Sql_condition::enum_severity_level  level,
const char *  msg,
bool  fatal_error = false 
)
private

Raise a generic SQL condition.

Also calls mysql_event_tracking_general_notify() unless the condition is handled by a SQL condition handler.

Parameters
sql_errnothe condition error number
sqlstatethe condition SQLSTATE
levelthe condition level
msgthe condition message text
fatal_errorshould the fatal_error flag be set?
Returns
The condition raised, or NULL

◆ raise_error()

void THD::raise_error ( uint  code)

Raise an exception condition.

Parameters
codethe MYSQL_ERRNO error code of the error

◆ raise_error_printf()

void THD::raise_error_printf ( uint  code,
  ... 
)

Raise an exception condition, with a formatted message.

Parameters
codethe MYSQL_ERRNO error code of the error

◆ raise_note()

void THD::raise_note ( uint  code)

Raise a completion condition (note), with a fixed message.

Parameters
codethe MYSQL_ERRNO error code of the note

◆ raise_note_printf()

void THD::raise_note_printf ( uint  code,
  ... 
)

Raise an completion condition (note), with a formatted message.

Parameters
codethe MYSQL_ERRNO error code of the note

◆ raise_warning()

void THD::raise_warning ( uint  code)

Raise a completion condition (warning).

Parameters
codethe MYSQL_ERRNO error code of the warning

◆ raise_warning_printf()

void THD::raise_warning_printf ( uint  code,
  ... 
)

Raise a completion condition (warning), with a formatted message.

Parameters
codethe MYSQL_ERRNO error code of the warning

◆ read_first_successful_insert_id_in_prev_stmt()

ulonglong THD::read_first_successful_insert_id_in_prev_stmt ( void  )
inline

◆ record_first_successful_insert_id_in_cur_stmt()

void THD::record_first_successful_insert_id_in_cur_stmt ( ulonglong  id_arg)
inline

◆ refresh_reference_caches()

void THD::refresh_reference_caches ( )
inline

◆ release_external_store()

void THD::release_external_store ( )

◆ release_resources()

void THD::release_resources ( )

Release most resources, prior to THD destruction.

◆ release_resources_done()

bool THD::release_resources_done ( ) const
Returns
true if THD resources are released.

◆ request_persist_gtid_by_se()

void THD::request_persist_gtid_by_se ( )
inline

Request SE to persist GTID explicitly.

◆ reset_binlog_local_stmt_filter()

void THD::reset_binlog_local_stmt_filter ( )
inline

◆ reset_copy_status_var()

void THD::reset_copy_status_var ( )
inline

Copy status variables into a structure pointed by the specified pointer passed into copy_status_var method call.

◆ reset_current_stmt_binlog_format_row()

void THD::reset_current_stmt_binlog_format_row ( )
inline

◆ reset_db()

void THD::reset_db ( const LEX_CSTRING new_db)
inline

Set the current database; use shallow copy of C-string.

Parameters
new_dbthe new database name.
Note
This operation just sets {db, db_length}. Switching the current database usually involves other actions, like switching other database attributes including security context. In the future, this operation will be made private and more convenient interface will be provided.

◆ reset_first_successful_insert_id()

void THD::reset_first_successful_insert_id ( )
inline

◆ reset_gtid_persisted_by_se()

void THD::reset_gtid_persisted_by_se ( )
inline

Reset by SE at transaction end after persisting GTID.

◆ reset_n_backup_open_tables_state()

void THD::reset_n_backup_open_tables_state ( Open_tables_backup backup,
uint  add_state_flags 
)

◆ reset_query()

void THD::reset_query ( )
inline

◆ reset_query_for_display()

void THD::reset_query_for_display ( )
inline

Reset query string to be displayed in PFS.

Also reset the safety flag for information_schema.process_list for next query.

◆ reset_rewritten_query()

void THD::reset_rewritten_query ( )
inline

Reset thd->m_rewritten_query.

Protected with the LOCK_thd_query mutex.

◆ reset_skip_readonly_check()

void THD::reset_skip_readonly_check ( )
inline

◆ reset_skip_transaction_read_only_check()

void THD::reset_skip_transaction_read_only_check ( )
inline

◆ reset_sub_statement_state()

void THD::reset_sub_statement_state ( Sub_statement_state backup,
uint  new_state 
)

◆ resource_group_ctx()

resourcegroups::Resource_group_ctx * THD::resource_group_ctx ( )
inline

Get resource group context.

Returns
pointer to resource group context.

◆ restore_backup_open_tables_state()

void THD::restore_backup_open_tables_state ( Open_tables_backup backup)

◆ restore_globals()

void THD::restore_globals ( )

◆ restore_ha_data()

void THD::restore_ha_data ( const Prealloced_array< Ha_data, PREALLOC_NUM_HA > &  backup)
inline

Restore ha_data from the provided backup copy.

Used by Attachable_Transaction.

◆ restore_sub_statement_state()

void THD::restore_sub_statement_state ( Sub_statement_state backup)

◆ rewritten_query()

const String & THD::rewritten_query ( ) const
inline

Get the rewritten query (with passwords obfuscated etc.) from the THD.

If done from a different thread (from the one that the rewritten_query is set on), the caller must hold LOCK_thd_query while calling this!

◆ rollback_item_tree_changes()

void THD::rollback_item_tree_changes ( )

Restore locations set by calls to nocheck_register_item_tree_change().

Note that this needs to happen before Item::cleanup is called.

◆ rpl_detach_engine_ha_data()

void THD::rpl_detach_engine_ha_data ( )

When the thread is a binlog or slave applier it detaches the engine ha_data associated with it and memorizes the fact of that.

◆ rpl_reattach_engine_ha_data()

void THD::rpl_reattach_engine_ha_data ( )

When the thread is a binlog or slave applier it reattaches the engine ha_data associated with it and memorizes the fact of that.

◆ safe_to_display()

bool THD::safe_to_display ( ) const
inline
Returns
true, if safe to display the query string.

◆ save_current_query_costs()

void THD::save_current_query_costs ( )
inline

Save the current query costs attributes in the thread session status.

Use this method only after the query execution is completed, so that

SHOW SESSION STATUS like 'last_query_%'
@ SHOW
Definition: sql_yacc.h:558
Definition: mysql.cc:153
SELECT * from performance_schema.session_status
WHERE VARIABLE_NAME like 'last_query_%'
const std::string SELECT("SELECT")
Name of the static privileges.
@ WHERE
Definition: sql_yacc.h:687

actually reports the previous query, not itself.

◆ se_persists_gtid()

bool THD::se_persists_gtid ( ) const
inline
Returns
true, if SE persists GTID for current transaction.

◆ se_persists_gtid_explicit()

bool THD::se_persists_gtid_explicit ( ) const
inline
Returns
true, if SE is explicitly set to persists GTID.

◆ secondary_engine_optimization()

Secondary_engine_optimization THD::secondary_engine_optimization ( ) const
inline

Can secondary storage engines be used for query execution in this session?

◆ secondary_engine_statement_context()

Secondary_engine_statement_context * THD::secondary_engine_statement_context ( )
inline

◆ security_context()

Security_context * THD::security_context ( ) const
inline

◆ send_explain_fields()

int THD::send_explain_fields ( Query_result result)

◆ send_kill_message()

void THD::send_kill_message ( ) const

◆ send_result_metadata()

bool THD::send_result_metadata ( const mem_root_deque< Item * > &  list,
uint  flags 
)

Send name and type of result to client.

Sum fields has table name empty and field_name.

Parameters
listList of items to send to client
flagsBit mask with the following functions:
  • 1 send number of rows
  • 2 send default values
  • 4 don't write eof packet
Return values
falseok
trueError (Note that in this case the error is not sent to the client)

◆ send_result_set_row()

bool THD::send_result_set_row ( const mem_root_deque< Item * > &  row_items)

Send one result set row.

Parameters
row_itemsa collection of column values for that row
Returns
Error status.
Return values
trueError.
falseSuccess.

◆ send_statement_status()

void THD::send_statement_status ( )

◆ set_active_vio()

void THD::set_active_vio ( Vio vio)
inline

◆ set_admin_connection()

void THD::set_admin_connection ( bool  admin)
inline

◆ set_binlog_local_stmt_filter()

void THD::set_binlog_local_stmt_filter ( )
inline

◆ set_catalog()

void THD::set_catalog ( const LEX_CSTRING catalog)
inline

◆ set_clone_vio()

void THD::set_clone_vio ( Vio vio)
inline

Set active clone network Vio for remote clone.

Parameters
[in]vionetwork vio

◆ set_command()

void THD::set_command ( enum enum_server_command  command)

◆ set_connection_admin()

void THD::set_connection_admin ( bool  connection_admin_flag)
inline

Sets the connection_admin flag atomically for the current session.

Parameters
[in]connection_admin_flagboolean flag that indicates value to set.

◆ set_current_stmt_binlog_format_row()

void THD::set_current_stmt_binlog_format_row ( )
inline

◆ set_current_stmt_binlog_format_row_if_mixed()

void THD::set_current_stmt_binlog_format_row_if_mixed ( )
inline

◆ set_db()

bool THD::set_db ( const LEX_CSTRING new_db)

Set the current database; use deep copy of C-string.

Parameters
new_dbthe new database name.

Initialize the current database from a NULL-terminated string with length. If we run out of memory, we free the current database and return true. This way the user will notice the error as there will be no current database selected (in addition to the error message set by malloc).

Note
This operation just sets {db, db_length}. Switching the current database usually involves other actions, like switching other database attributes including security context. In the future, this operation will be made private and more convenient interface will be provided.
Returns
Operation status
Return values
falseSuccess
trueOut-of-memory error

◆ set_gtid_persisted_by_se()

void THD::set_gtid_persisted_by_se ( )
inline

Set by SE when it guarantees GTID persistence.

◆ set_invoker()

void THD::set_invoker ( const LEX_STRING user,
const LEX_STRING host 
)
inline

◆ set_is_killable()

void THD::set_is_killable ( bool  is_killable_arg)
inline

Assign a new value to is_killable Protected with the LOCK_thd_data mutex.

◆ set_log_reset()

void THD::set_log_reset ( )
inline

Set when binlog reset operation is started.

◆ set_new_thread_id()

void THD::set_new_thread_id ( )

Assign a value to m_thread_id by calling Global_THD_manager::get_new_thread_id().

◆ set_next_event_pos()

void THD::set_next_event_pos ( const char *  _filename,
ulonglong  _pos 
)

◆ set_open_tables()

void THD::set_open_tables ( TABLE open_tables_arg)
inline

Assign a new value to open_tables.

Protected with the LOCK_thd_data mutex.

◆ set_original_commit_timestamp_for_slave_thread()

void THD::set_original_commit_timestamp_for_slave_thread ( )

Copies variables.original_commit_timestamp to ((Slave_worker *)rli_slave)->original_commit_timestamp, if this is a slave thread.

◆ set_plugin()

void THD::set_plugin ( const st_plugin_int plugin)
inline

Sets the plugin id to the value provided as parameter.

Parameters
pluginthe id of the plugin the thd belongs to

◆ set_proc_info()

void THD::set_proc_info ( const char *  proc_info)
inline

◆ set_psi()

void THD::set_psi ( PSI_thread psi)
inline

Save the performance schema thread instrumentation associated with this user session.

Parameters
psiPerformance schema thread instrumentation

◆ set_query() [1/2]

void THD::set_query ( const char *  query_arg,
size_t  query_length_arg 
)
inline

Assign a new value to thd->m_query_string.

Protected with the LOCK_thd_query mutex.

◆ set_query() [2/2]

void THD::set_query ( LEX_CSTRING  query_arg)

◆ set_query_for_display()

void THD::set_query_for_display ( const char *  query_arg,
size_t  query_length_arg 
)
inline

Set query to be displayed in performance schema (threads table etc.).

Also mark the query safe to display for information_schema.process_list.

◆ set_query_id()

void THD::set_query_id ( query_id_t  new_query_id)
inline

Assign a new value to thd->query_id.

Protected with the LOCK_thd_data mutex.

◆ set_row_count_func()

void THD::set_row_count_func ( longlong  row_count_func)
inline

◆ set_safe_display()

void THD::set_safe_display ( bool  safe)
inline

Set if the query string to be safe to display.

Parameters
[in]safeif it is safe to display query string

◆ set_secondary_engine_forced()

void THD::set_secondary_engine_forced ( bool  forced)
inline

Indicate whether secondary storage engine is forced for this execution.

◆ set_secondary_engine_optimization()

void THD::set_secondary_engine_optimization ( Secondary_engine_optimization  state)
inline

Enables or disables use of secondary storage engines in this session.

◆ set_secondary_engine_statement_context()

void THD::set_secondary_engine_statement_context ( std::unique_ptr< Secondary_engine_statement_context context)

◆ set_security_context()

void THD::set_security_context ( Security_context sctx)
inline

◆ set_sent_row_count()

void THD::set_sent_row_count ( ha_rows  count)

◆ set_server_id()

void THD::set_server_id ( uint32  sid)
inline

◆ set_skip_readonly_check()

void THD::set_skip_readonly_check ( )
inline

◆ set_skip_transaction_read_only_check()

void THD::set_skip_transaction_read_only_check ( )
inline

◆ set_ssl()

void THD::set_ssl ( Vio vio)
inline

◆ set_status_no_good_index_used()

void THD::set_status_no_good_index_used ( )

◆ set_status_no_index_used()

void THD::set_status_no_index_used ( )

◆ set_system_user()

void THD::set_system_user ( bool  system_user_flag)
inline

Sets the system_user flag atomically for the current session.

Parameters
[in]system_user_flagboolean flag that indicates value to set.

◆ set_time() [1/2]

void THD::set_time ( )

◆ set_time() [2/2]

void THD::set_time ( const struct timeval *  t)
inline

◆ set_tmp_table_seq_id()

void THD::set_tmp_table_seq_id ( uint  arg)
inline

◆ set_trans_pos()

void THD::set_trans_pos ( const char *  file,
my_off_t  pos 
)
inline

Functions to set and get transaction position.

These functions are used to set the transaction position for the transaction written when committing this transaction.

◆ set_transaction()

void THD::set_transaction ( Transaction_ctx transaction_ctx)

Changes the Transaction_ctx instance within THD-object.

The previous Transaction_ctx instance is destroyed.

Note
this is a THD-internal operation which MUST NOT be used outside.
Parameters
transaction_ctxnew Transaction_ctx instance to be associated with the THD-object.

◆ set_user_connect()

void THD::set_user_connect ( USER_CONN uc)

◆ set_waiting_for_disk_space()

void THD::set_waiting_for_disk_space ( bool  waiting)
inline

Set the waiting_for_disk_space flag.

Parameters
waitingThe value to set in the flag.

◆ shutdown_active_vio()

void THD::shutdown_active_vio ( )

◆ shutdown_clone_vio()

void THD::shutdown_clone_vio ( )

Shutdown clone vio, if active.

◆ sql_parser()

bool THD::sql_parser ( )

Call parser to transform statement into a parse tree.

Then, transform the parse tree further into an AST, ready for resolving.

◆ start_disposal()

void THD::start_disposal ( )
private

Set THD in ACTIVE life stage to disposal stage.

To avoid race conditions with non-owner thread checking THD disposal state, LOCK_thd_data should be acquired before changing THD stage to disposal stage.

◆ store_globals()

void THD::store_globals ( )

◆ strmake()

char * THD::strmake ( const char *  str,
size_t  size 
) const
inline

◆ swap_rewritten_query()

void THD::swap_rewritten_query ( String query_arg)

Set the rewritten query (with passwords obfuscated etc.) on the THD.

Wraps this in the LOCK_thd_query mutex to protect against race conditions with SHOW PROCESSLIST inspecting that string.

This uses swap() and therefore "steals" the argument from the caller; the caller MUST take care not to try to use its own string after calling this function! This is an optimization for mysql_rewrite_query() so we don't copy its temporary string (which may get very long, up to @max_allowed_packet).

Using this outside of mysql_rewrite_query() is almost certainly wrong; please check with the runtime team!

Parameters
query_argThe rewritten query to use for slow/bin/general logging. The value will be released in the caller and MUST NOT be used there after calling this function.

◆ syntax_error() [1/3]

void THD::syntax_error ( )
inline

◆ syntax_error() [2/3]

void THD::syntax_error ( const char *  format,
  ... 
)

Push an error message into MySQL diagnostic area with line number and position.

This function provides semantic action implementers with a way to push the famous "You have a syntax error near..." error message into the diagnostic area, which is normally produced only if a syntax error is discovered according to the Bison grammar. Unlike the syntax_error_at() function, the error position points to the last parsed token.

Note
Parse-time only function!
Parameters
formatError format message. NULL means ER(ER_SYNTAX_ERROR).

◆ syntax_error() [3/3]

void THD::syntax_error ( int  mysql_errno,
  ... 
)

Push an error message into MySQL diagnostic area with line number and position.

This function provides semantic action implementers with a way to push the famous "You have a syntax error near..." error message into the diagnostic area, which is normally produced only if a syntax error is discovered according to the Bison grammar. Unlike the syntax_error_at() function, the error position points to the last parsed token.

Note
Parse-time only function!
Parameters
mysql_errnoError number to get a format string with ER_THD().

◆ syntax_error_at() [1/3]

void THD::syntax_error_at ( const POS location)
inline

◆ syntax_error_at() [2/3]

void THD::syntax_error_at ( const POS location,
const char *  format,
  ... 
)

Push a syntax error message into MySQL diagnostic area with line and position information.

This function provides semantic action implementers with a way to push the famous "You have a syntax error near..." error message into the diagnostic area, which is normally produced only if a parse error is discovered internally by the Bison generated parser.

Note
Parse-time only function!
Parameters
locationYYSTYPE object: error position.
formatError format message. NULL means ER(ER_SYNTAX_ERROR).

◆ syntax_error_at() [3/3]

void THD::syntax_error_at ( const POS location,
int  mysql_errno,
  ... 
)

Push a syntax error message into MySQL diagnostic area with line and position information.

This function provides semantic action implementers with a way to push the famous "You have a syntax error near..." error message into the diagnostic area, which is normally produced only if a parse error is discovered internally by the Bison generated parser.

Note
Parse-time only function!
Parameters
locationYYSTYPE object: error position
mysql_errnoError number to get a format string with ER_THD()

◆ thread_id()

my_thread_id THD::thread_id ( ) const
inline

◆ time_out_user_resource_limits()

void THD::time_out_user_resource_limits ( )

◆ time_zone()

Time_zone * THD::time_zone ( )
inline

◆ unlock_query_plan()

void THD::unlock_query_plan ( )
inline

◆ unpin_gtid()

void THD::unpin_gtid ( )
inline

Unpin and free GTID and TSID.

◆ update_charset()

void THD::update_charset ( )

◆ update_previous_found_rows()

void THD::update_previous_found_rows ( )
inline

◆ update_slow_query_status()

void THD::update_slow_query_status ( )

Evaluate the current time, and if it exceeds the long-query-time setting, mark the query as slow.

◆ vsyntax_error_at() [1/2]

void THD::vsyntax_error_at ( const char *  pos_in_lexer_raw_buffer,
const char *  format,
va_list  args 
)

Push a syntax error message into MySQL diagnostic area with line number and position.

This function provides semantic action implementers with a way to push the famous "You have a syntax error near..." error message into the error stack, which is normally produced only if a parse error is discovered internally by the Bison generated parser.

Parameters
pos_in_lexer_raw_bufferPointer into LEX::m_buf or NULL.
formatAn error message format string.
argsArguments to the format string.

◆ vsyntax_error_at() [2/2]

void THD::vsyntax_error_at ( const POS location,
const char *  format,
va_list  args 
)

Friends And Related Function Documentation

◆ my_message_sql

void my_message_sql ( uint  ,
const char *  ,
myf   
)
friend

All global error messages are sent here where the first one is stored for the client.

◆ Protocol_classic

friend class Protocol_classic
friend

◆ push_warning

void push_warning ( THD thd,
Sql_condition::enum_severity_level  severity,
uint  code,
const char *  message_text 
)
friend

Push the warning to error list if there is still room in the list.

Parameters
thdThread handle
severitySeverity of warning (note, warning)
codeError number
message_textClear error message

◆ Sql_cmd_common_signal

friend class Sql_cmd_common_signal
friend

◆ Sql_cmd_resignal

friend class Sql_cmd_resignal
friend

◆ Sql_cmd_signal

friend class Sql_cmd_signal
friend

Member Data Documentation

◆ active_vio

Vio* THD::active_vio = {nullptr}

◆ arg_of_last_insert_id_function

bool THD::arg_of_last_insert_id_function

◆ audit_class_mask

Prealloced_array<unsigned long, 11> THD::audit_class_mask

Array of bits indicating which audit classes have already been added to the list of audit plugins which are currently in use.

◆ audit_class_plugins

Plugin_array THD::audit_class_plugins

Array of active audit plugins which have been used by this THD.

This list is later iterated to invoke release_thd() on those plugins.

◆ audit_plugins_present

bool THD::audit_plugins_present
private

◆ auto_inc_intervals_forced

Discrete_intervals_list THD::auto_inc_intervals_forced

◆ auto_inc_intervals_in_cur_stmt_for_binlog

Discrete_intervals_list THD::auto_inc_intervals_in_cur_stmt_for_binlog

◆ bind_parameter_values

PS_PARAM* THD::bind_parameter_values

The parameter value bindings for the current query.

Allocated on the THD memroot. Can be empty

◆ bind_parameter_values_count

unsigned long THD::bind_parameter_values_count

the number of elements in parameters

◆ binlog_accessed_db_names

List<char>* THD::binlog_accessed_db_names
private

◆ 

struct { ... } THD::binlog_evt_union

◆ binlog_need_explicit_defaults_ts

bool THD::binlog_need_explicit_defaults_ts

The member is served for marking a query that CREATEs or ALTERs a table declared with a TIMESTAMP column as dependent on @session.explicit_defaults_for_timestamp.

Is set to true by parser, unset at the end of the query. Possible marking in checked by binary logger.

◆ binlog_next_event_pos

rpl_event_coordinates THD::binlog_next_event_pos

◆ binlog_row_event_extra_data

uchar* THD::binlog_row_event_extra_data

◆ binlog_table_maps

uint THD::binlog_table_maps
private

◆ binlog_unsafe_warning_flags

uint32 THD::binlog_unsafe_warning_flags
private

Bit field for the state of binlog warnings.

The first Lex::BINLOG_STMT_UNSAFE_COUNT bits list all types of unsafeness that the current statement has.

This must be a member of THD and not of LEX, because warnings are detected and issued in different places (decide_logging_format() and binlog_query(), respectively). Between these calls, the THD->lex object may change; e.g., if a stored routine is invoked. Only THD persists between the calls.

◆ bool_value

bool THD::bool_value

◆ change_list

Item_change_list THD::change_list

This is used to track transient changes to items during optimization of a prepared statement/stored procedure.

Change objects are created by change_item_tree() in memory root of THD, and freed by rollback_item_tree_changes(). Changes recorded here are rolled back at the end of execution.

Transient changes require the following conditions:

  • The statement is not regular (ie. it is prepared or part of SP).
  • The change is performed outside preparation code (ie. it is performed during the optimization phase).
  • The change is applied to non-transient items (ie. items that have been created before or during preparation, not items that have been created in the optimization phase. Notice that the tree of AND/OR conditions is always as transient objects during optimization. Doing this should be quite harmless, though.) change_item_tree() only records changes to non-regular statements. It is also ensured that no changes are applied in preparation phase by asserting that the list of items is empty (see Sql_cmd_dml::prepare()). Other constraints are not enforced, in particular care must be taken so that all changes made during optimization to non-transient Items in non-regular statements must be recorded.

◆ charset_is_character_set_filesystem

bool THD::charset_is_character_set_filesystem

◆ charset_is_collation_connection

bool THD::charset_is_collation_connection

◆ charset_is_system_charset

bool THD::charset_is_system_charset

is set if a statement accesses a temporary table created through CREATE TEMPORARY TABLE.

◆ check_for_truncated_fields

enum_check_fields THD::check_for_truncated_fields

◆ clone_vio

Vio* THD::clone_vio = {nullptr}

◆ commit_error

enum THD::Commit_error THD::commit_error

◆ COND_group_replication_connection_cond_var

mysql_cond_t THD::COND_group_replication_connection_cond_var

◆ COND_thr_lock

mysql_cond_t THD::COND_thr_lock

Condition variable used for waiting by the THR_LOCK.c subsystem.

◆ conn_mem_alloc_number

ulonglong THD::conn_mem_alloc_number

◆ copy_status_var_ptr

struct System_status_var* THD::copy_status_var_ptr

◆ current_cond

std::atomic<mysql_cond_t *> THD::current_cond

Pointer to the condition variable the thread owning this THD is currently waiting for.

If the thread is not waiting, the value is NULL. Set by THD::enter_cond().

If this thread is killed (shutdown or KILL stmt), another thread will broadcast on this condition variable so that the thread can be unstuck.

◆ current_found_rows

ulonglong THD::current_found_rows

Dynamic, collected and set also in subqueries.

Not stable throughout query. previous_found_rows is a snapshot of this take at query end making it stable throughout the next query, see update_previous_found_rows.

◆ current_key_name

const char* THD::current_key_name

◆ current_mutex

std::atomic<mysql_mutex_t *> THD::current_mutex

The mutex used with current_cond.

See also
current_cond

◆ current_stmt_binlog_format

enum_binlog_format THD::current_stmt_binlog_format
private

Indicates the format in which the current statement will be logged.

This can only be set from decide_logging_format().

◆ db_charset

const CHARSET_INFO* THD::db_charset

◆ dbug_sentry

uint THD::dbug_sentry

◆ debug_binlog_xid_last

XID THD::debug_binlog_xid_last

◆ DEFAULT_WHERE

const char *const THD::DEFAULT_WHERE = "field list"
static

◆ derived_tables_processing

bool THD::derived_tables_processing

◆ do_union

bool THD::do_union

◆ double_value

double THD::double_value

◆ duplicate_slave_id

bool THD::duplicate_slave_id

This is only used by master dump threads.

When the master receives a new connection from a slave with a UUID (for slave versions >= 5.6)/server_id(for slave versions < 5.6) that is already connected, it will set this flag true before killing the old slave connection.

◆ durability_property

enum durability_properties THD::durability_property

◆ enable_slow_log

bool THD::enable_slow_log

◆ event_tracking_data_

Event_tracking_data_stack THD::event_tracking_data_
private

◆ events_cache_

Event_reference_caching_cache* THD::events_cache_ {nullptr}
private

◆ external_store_

std::unordered_map<unsigned int, void *> THD::external_store_
private

◆ file_id

uint32 THD::file_id

◆ fill_status_recursion_level

uint THD::fill_status_recursion_level

Used by fill_status() to avoid acquiring LOCK_status mutex twice when this function is called recursively (e.g.

queries that contains SELECT on I_S.GLOBAL_STATUS with subquery on the same I_S table). Incremented each time fill_status() function is entered and decremented each time before it returns from the function.

◆ fill_variables_recursion_level

uint THD::fill_variables_recursion_level

◆ first_query_id

query_id_t THD::first_query_id

◆ first_successful_insert_id_in_cur_stmt

ulonglong THD::first_successful_insert_id_in_cur_stmt

◆ first_successful_insert_id_in_prev_stmt

ulonglong THD::first_successful_insert_id_in_prev_stmt

◆ first_successful_insert_id_in_prev_stmt_for_binlog

ulonglong THD::first_successful_insert_id_in_prev_stmt_for_binlog

◆ for_debug_only_is_set_persist_options

bool THD::for_debug_only_is_set_persist_options {false}

◆ global_read_lock

Global_read_lock THD::global_read_lock

◆ ha_data

Prealloced_array<Ha_data, PREALLOC_NUM_HA> THD::ha_data
private

◆ handler_tables_hash

collation_unordered_map<std::string, unique_ptr_my_free<Table_ref> > THD::handler_tables_hash
Initial value:
MYSQL_STRINGS_EXPORT CHARSET_INFO my_charset_latin1
Definition: ctype-latin1.cc:366
PSI_memory_key key_memory_THD_handler_tables_hash
Definition: psi_memory_key.cc:93

◆ has_gtid_consistency_violation

bool THD::has_gtid_consistency_violation

◆ has_incremented_gtid_automatic_count

bool THD::has_incremented_gtid_automatic_count

Flag indicating whether this session incremented the number of sessions with GTID_NEXT set to AUTOMATIC:tag.

◆ in_loadable_function

bool THD::in_loadable_function {false}

◆ in_lock_tables

bool THD::in_lock_tables

◆ in_sub_stmt

uint THD::in_sub_stmt

◆ initial_status_var

struct System_status_var* THD::initial_status_var

◆ insert_lock_default

thr_lock_type THD::insert_lock_default

Type of lock to be used for INSERT statement if lock is not specified explicitly.

Set to TL_WRITE_CONCURRENT_INSERT or TL_WRITE_LOW_PRIORITY depending on whether low_priority_updates option is off or on.

◆ is_a_srv_session_thd

bool THD::is_a_srv_session_thd
private

Variable to mark if the object is part of a Srv_session object, which aggregates THD.

◆ is_commit_in_middle_of_statement

bool THD::is_commit_in_middle_of_statement

◆ is_fatal_sub_stmt_error

bool THD::is_fatal_sub_stmt_error

true if we are in a sub-statement and the current error can not be safely recovered until we left the sub-statement mode.

In particular, disables activation of CONTINUE and EXIT handlers inside sub-statements. E.g. if it is a deadlock error and requires a transaction-wide rollback, this flag is raised (traditionally, MySQL first has to close all the reads via

See also
handler::ha_index_or_rnd_end() and only then perform the rollback). Reset to false when we leave the sub-statement mode.

◆ is_killable

bool THD::is_killable

◆ is_mem_cnt_error_issued

bool THD::is_mem_cnt_error_issued

◆ is_operating_gtid_table_implicitly

bool THD::is_operating_gtid_table_implicitly

◆ is_operating_substatement_implicitly

bool THD::is_operating_substatement_implicitly

◆ is_slave_error

bool THD::is_slave_error

True if a slave error.

Causes the slave to stop. Not the same as the statement execution error (is_error()), since a statement may be expected to return an error, e.g. because it returned an error on master, and this is OK on the slave.

◆ kill_immunizer

dd::DD_kill_immunizer* THD::kill_immunizer

When operation on DD tables is in progress then THD is set to kill immune mode.

This member holds DD_kill_immunizer object created to make DD operations immune from the kill operations. Member also indicated whether THD is in kill immune mode or not.

◆ killed

std::atomic<killed_state> THD::killed

◆ lex

LEX* THD::lex

◆ LOCK_current_cond

mysql_mutex_t THD::LOCK_current_cond

Mutex protecting access to current_mutex and current_cond.

◆ LOCK_group_replication_connection_mutex

mysql_mutex_t THD::LOCK_group_replication_connection_mutex

◆ lock_info

THR_LOCK_INFO THD::lock_info

◆ LOCK_query_plan

mysql_mutex_t THD::LOCK_query_plan
private

Protects query plan (SELECT/UPDATE/DELETE's) from being freed/changed while another thread explains it.

Following structures are protected by this mutex: THD::Query_plan Modification_plan Query_block::join JOIN::plan_state Tree of Query_expression after THD::Query_plan was set till THD::Query_plan cleanup JOIN_TAB::select->quick Code that changes objects above should take this mutex. Explain code takes this mutex to block changes to named structures to avoid crashes in following functions: explain_single_table_modification explain_query Sql_cmd_explain_other_thread::execute When doing EXPLAIN CONNECTION: all explain code assumes that this mutex is already taken. When doing ordinary EXPLAIN: the mutex does need to be taken (no need to protect reading my own data, moreover EXPLAIN CONNECTION can't run on an ordinary EXPLAIN).

◆ LOCK_thd_data

mysql_mutex_t THD::LOCK_thd_data

Protects THD data accessed from other threads.

The attributes protected are:

  • thd->is_killable (used by KILL statement and shutdown).
  • thd->user_vars (user variables, inspected by monitoring) Is locked when THD is deleted.

◆ LOCK_thd_protocol

mysql_mutex_t THD::LOCK_thd_protocol

Protects THD::m_protocol when it gets removed in x plugin.

◆ LOCK_thd_query

mysql_mutex_t THD::LOCK_thd_query

Protects THD::m_query_string.

No other mutexes should be locked while having this mutex locked.

◆ LOCK_thd_security_ctx

mysql_mutex_t THD::LOCK_thd_security_ctx

Protects THD::m_security_ctx from inspection (e.g.

by old-style SHOW PROCESSLIST) while COM_CHANGE_USER changes the context.

◆ LOCK_thd_sysvar

mysql_mutex_t THD::LOCK_thd_sysvar

Protects THD::variables while being updated.

This should be taken inside of LOCK_thd_data and outside of LOCK_global_system_variables.

◆ locked_tables_list

Locked_tables_list THD::locked_tables_list

◆ long_value

long THD::long_value

◆ m_attachable_trx

Attachable_trx* THD::m_attachable_trx
private

◆ m_audited

bool THD::m_audited

◆ m_binlog_filter_state

binlog_filter_state THD::m_binlog_filter_state
private

Indicate if the current statement should be discarded instead of written to the binlog.

This is used to discard special statements, such as DML or DDL that affects only 'local' (non replicated) tables, such as performance_schema.*

◆ m_binlog_invoker

bool THD::m_binlog_invoker
private

It will be set TRUE if CURRENT_USER() is called in account management statements or default definer is set in CREATE/ALTER SP, SF, Event, TRIGGER or VIEW statements.

Current user will be binlogged into Query_log_event if current_user_used is true; It will be stored into m_invoker_host and m_invoker_user by SQL thread.

◆ m_cached_is_connection_alive

std::atomic<bool> THD::m_cached_is_connection_alive
private

Keep a cached value saying whether the connection is alive.

Update when pushing, popping or getting the protocol. Used by information_schema.processlist to avoid locking mutexes that might affect performance.

◆ m_catalog

LEX_CSTRING THD::m_catalog
private

Currently selected catalog.

◆ m_command

enum enum_server_command THD::m_command
private

Type of current query: COM_STMT_PREPARE, COM_QUERY, etc.

Set from first byte of the packet in do_command()

◆ m_connection_attributes

std::vector<char> THD::m_connection_attributes

Session's connection attributes for the connected client.

◆ m_cost_model

Cost_model_server THD::m_cost_model
private

Optimizer cost model for server operations.

◆ m_cost_model_hypergraph

Cost_model_server THD::m_cost_model_hypergraph
private

◆ m_current_query_cost

double THD::m_current_query_cost

Current query cost.

See also
system_status_var::last_query_cost

◆ m_current_query_partial_plans

ulonglong THD::m_current_query_partial_plans

Current query partial plans.

See also
system_status_var::last_query_partial_plans

◆ m_current_stage_key

PSI_stage_key THD::m_current_stage_key
private

◆ m_db

LEX_CSTRING THD::m_db
private

Name of the current (default) database.

If there is the current (default) database, "db" contains its name. If there is no current (default) database, "db" is NULL and "db_length" is 0. In other words, "db", "db_length" must either be NULL, or contain a valid database name.

Note
this attribute is set and allocated by the slave SQL thread (for the THD of that thread); that thread is (and must remain, for now) the only responsible for freeing this member.

◆ m_dd_client

std::unique_ptr<dd::cache::Dictionary_client> THD::m_dd_client
private

◆ m_digest

sql_digest_state* THD::m_digest

Current statement digest.

◆ m_digest_state

sql_digest_state THD::m_digest_state

Top level statement digest.

◆ m_disable_password_validation

bool THD::m_disable_password_validation
Note
The optional password validation plugin doesn't have any API for temporally disable its functionality for a particular session. To get around this issue we introduce a boolean variable in the THD which we check before each call to the password validation plugin. Password validation is invoked from within the authentication plugin in the generate_authentication_string() method.
See also
generate_authentication_string

◆ m_enable_plugins

bool THD::m_enable_plugins

◆ m_examined_row_count

ha_rows THD::m_examined_row_count
private

Number of rows read and/or evaluated for a statement.

Used for slow log reporting.

An examined row is defined as a row that is read and/or evaluated according to a statement condition, including in create_sort_index(). Rows may be counted more than once, e.g., a statement including ORDER BY could possibly evaluate the row in filesort() before reading it for e.g. update.

◆ m_idle_psi

PSI_idle_locker* THD::m_idle_psi

Idle instrumentation.

◆ m_idle_state

PSI_idle_locker_state THD::m_idle_state

Idle instrumentation state.

◆ m_inside_system_variable_global_update

bool THD::m_inside_system_variable_global_update

Flag to indicate this thread is executing sys_var::update for a OPT_GLOBAL variable.

This flag imply the thread already holds LOCK_global_system_variables. Knowing this is required to resolve reentrancy issues in the system variable code, when callers read system variable Y while inside an update function for system variable X. Executing table io while inside a system variable update function will indirectly cause this.

◆ m_internal_handler

Internal_error_handler* THD::m_internal_handler
private

The current internal error handler for this thread, or NULL.

◆ m_invoker_host

LEX_CSTRING THD::m_invoker_host
private

◆ m_invoker_user

LEX_CSTRING THD::m_invoker_user
private

It points to the invoker in the Query_log_event.

SQL thread use it as the default definer in CREATE/ALTER SP, SF, Event, TRIGGER or VIEW statements or current user in account management statements if it is not NULL.

◆ m_is_admin_conn

bool THD::m_is_admin_conn
private

◆ m_is_connection_admin

std::atomic<bool> THD::m_is_connection_admin
private

Flag that indicates if the user of current session has CONNECTION_ADMIN privilege.

◆ m_is_fatal_error

bool THD::m_is_fatal_error
private

Set to true if execution of the current compound statement can not continue.

In particular, disables activation of CONTINUE or EXIT handlers of stored routines. Reset in the end of processing of the current user request, in

See also
mysql_reset_thd_for_next_command().

◆ m_is_low_level_commit_ordering_enabled

bool THD::m_is_low_level_commit_ordering_enabled = false
private

Flag indicating whether additional ordering in the ha_commit_low function is enabled.

If disabled, ordering will take place in binlog::commit. It is set up in binlog::commit

◆ m_is_plugin_fake_ddl

bool THD::m_is_plugin_fake_ddl
private

Creating or dropping plugin native table through a plugin service.

This variable enables the DDL command execution from dd::create_native_table() to be executed without committing the transaction.

◆ m_is_system_user

std::atomic<bool> THD::m_is_system_user
private

Flag that indicates if the user of current session has SYSTEM_USER privilege.

◆ m_lock_usec

ulonglong THD::m_lock_usec
private

Time spent waiting for TABLE locks and DATA locks.

Expressed in microseconds.

◆ m_main_security_ctx

Security_context THD::m_main_security_ctx
Note
Some members of THD (currently 'Statement::db', 'catalog' and 'query') are set and allocated by the slave SQL thread (for the THD of that thread); that thread is (and must remain, for now) the only responsible for freeing these 3 members. If you add members here, and you add code to set them in replication, don't forget to free_them_and_set_them_to_0 in replication properly. For details see the 'err:' label of the handle_slave_sql() in sql/slave.cc.
See also
handle_slave_sql

◆ m_mem_cnt

Thd_mem_cnt THD::m_mem_cnt

Controlled memory stats for this session.

This member is the first in THD, to initialize Thd_mem_cnt() before allocating more memory.

◆ m_net_server_extension

NET_SERVER THD::m_net_server_extension

Additional network instrumentation for the server only.

◆ m_normalized_query

String THD::m_normalized_query
private

◆ m_parser_da

Diagnostics_area THD::m_parser_da
private

cf.

get_parser_da()

◆ m_parser_state

Parser_state * THD::m_parser_state

Internal parser state.

Note that since the parser is not re-entrant, we keep only one parser state here. This member is valid only when executing code during parsing.

◆ m_plugin

const st_plugin_int* THD::m_plugin {nullptr}
private

Stores the plugin id it is attached to (if any).

◆ m_proc_info

const char* THD::m_proc_info
private

◆ m_protocol

Protocol* THD::m_protocol
private

◆ m_psi

std::atomic<PSI_thread *> THD::m_psi
private

Performance schema thread instrumentation for this session.

This member is maintained using atomic operations, do not access it directly.

See also
set_psi
get_psi

◆ m_query_rewrite_plugin_da

Diagnostics_area THD::m_query_rewrite_plugin_da
private

◆ m_query_rewrite_plugin_da_ptr

Diagnostics_area* THD::m_query_rewrite_plugin_da_ptr
private

◆ m_query_string

LEX_CSTRING THD::m_query_string
private

The query associated with this statement.

◆ m_resource_group_ctx

resourcegroups::Resource_group_ctx THD::m_resource_group_ctx
private

Resource group context indicating the current resource group and the name of the resource group to switch to during execution of a query.

◆ m_rewritten_query

String THD::m_rewritten_query
private

In some cases, we may want to modify the query (i.e.

replace passwords with their hashes before logging the statement etc.).

In case the query was rewritten, the original query will live in m_query_string, while the rewritten query lives in rewritten_query. If rewritten_query is empty, m_query_string should be logged. If rewritten_query is non-empty, the rewritten query it contains should be used in logs (general log, slow query log, binary log).

Currently, password obfuscation is the only rewriting we do; more may follow at a later date, both pre- and post parsing of the query. Rewriting of binloggable statements must preserve all pertinent information.

Similar restrictions as for m_query_string (see there) hold for locking:

  • Value may only be (re)set from owning thread (current_thd)
  • Value must be modified using (reset|swap)_rewritten_query(). Doing so will protect the update with LOCK_thd_query.
  • The owner (current_thd) may read the value without holding the lock.
  • Other threads may read the value, but must hold LOCK_thd_query to do so.

◆ m_row_count_func

longlong THD::m_row_count_func
private

Stores the result of ROW_COUNT() function.

ROW_COUNT() function is a MySQL extension, but we try to keep it similar to ROW_COUNT member of the GET DIAGNOSTICS stack of the SQL standard (see SQL99, part 2, search for ROW_COUNT). Its value is implementation defined for anything except INSERT, DELETE, UPDATE.

ROW_COUNT is assigned according to the following rules:

  • In my_ok():
    • for DML statements: to the number of affected rows;
    • for DDL statements: to 0.
  • In my_eof(): to -1 to indicate that there was a result set.

    We derive this semantics from the JDBC specification, where int java.sql.Statement.getUpdateCount() is defined to (sic) "return the current result as an update count; if the result is a ResultSet object or there are no more results, -1 is returned".

  • In my_error(): to -1 to be compatible with the MySQL C API and MySQL ODBC driver.
  • For SIGNAL statements: to 0 per WL#2110 specification (see also sql_signal.cc comment). Zero is used since that's the "default" value of ROW_COUNT in the Diagnostics Area.

◆ m_safe_to_display

std::atomic<bool> THD::m_safe_to_display
private

◆ m_se_gtid_flags

Se_GTID_flagset THD::m_se_gtid_flags

Flags for SE GTID persistence.

◆ m_secondary_engine_forced

bool THD::m_secondary_engine_forced {false}
private

Flag that tells whether secondary storage engine is forced for execution.

Notice that use_secondary_engine is not reliable because it may be restored early.

◆ m_secondary_engine_optimization

Secondary_engine_optimization THD::m_secondary_engine_optimization
private
Initial value:
=
@ PRIMARY_ONLY
The current statement should only use tables from primary storage engines.

This flag tells if a secondary storage engine can be used to execute a query in this session.

◆ m_secondary_engine_statement_context

std::unique_ptr<Secondary_engine_statement_context> THD::m_secondary_engine_statement_context
private

Current query's secondary engine statement context.

◆ m_security_ctx

Security_context* THD::m_security_ctx

◆ m_sent_row_count

ha_rows THD::m_sent_row_count
private

Number of rows we actually sent to the client, including "synthetic" rows in ROLLUP etc.

◆ m_server_idle

bool THD::m_server_idle

True if the server code is IDLE for this connection.

◆ m_SSL

SSL_handle THD::m_SSL = {nullptr}
private

SSL data attached to this connection.

This is an opaque pointer, When building with SSL, this pointer is non NULL only if the connection is using SSL. When building without SSL, this pointer is always NULL. The SSL data can be inspected to read per thread status variables, and this can be inspected while the thread is running.

◆ m_stage_progress_psi

PSI_stage_progress* THD::m_stage_progress_psi

Current stage progress instrumentation.

◆ m_statement_psi

PSI_statement_locker* THD::m_statement_psi

Current statement instrumentation.

◆ m_statement_state

PSI_statement_locker_state THD::m_statement_state

Current statement instrumentation state.

◆ m_stmt_da

Diagnostics_area* THD::m_stmt_da
private

◆ m_thd_life_cycle_stage

enum_thd_life_cycle_stages THD::m_thd_life_cycle_stage
private
Initial value:
{
enum_thd_life_cycle_stages::ACTIVE}

◆ m_thread_id

my_thread_id THD::m_thread_id
private

This counter is 32 bit because of the client protocol.

Note
It is not meant to be used for my_thread_self(), see real_id for this.
Set to reserved_thread_id on initialization. This is a magic value that is only to be used for temporary THDs not present in the global THD list.

◆ m_token_array

unsigned char* THD::m_token_array

Current statement digest token array.

◆ m_trans_end_pos

my_off_t THD::m_trans_end_pos
private

◆ m_trans_fixed_log_file

char* THD::m_trans_fixed_log_file
private

◆ m_trans_log_file

const char* THD::m_trans_log_file
private

The binary log position of the transaction.

The file and position are zero if the current transaction has not been written to the binary log.

See also
set_trans_pos
get_trans_pos

◆ m_transaction

std::unique_ptr<Transaction_ctx> THD::m_transaction
private

◆ m_transaction_psi

PSI_transaction_locker* THD::m_transaction_psi

Current transaction instrumentation.

◆ m_transaction_state

PSI_transaction_locker_state THD::m_transaction_state

Current transaction instrumentation state.

◆ m_transactional_ddl

Transactional_ddl_context THD::m_transactional_ddl {this}

◆ m_user_connect

USER_CONN* THD::m_user_connect
private

◆ m_view_ctx_list

List<Security_context> THD::m_view_ctx_list

◆ main_da

Diagnostics_area THD::main_da
private

◆ main_lex

std::unique_ptr<LEX> THD::main_lex
private

The lex to hold the parsed tree of conventional (non-prepared) queries.

Whereas for prepared and stored procedure statements we use an own lex instance for each new query, for conventional statements we reuse the same lex. (

See also
dispatch_sql_command for details).

◆ main_mem_root

MEM_ROOT THD::main_mem_root
private

This memory root is used for two purposes:

  • for conventional queries, to allocate structures stored in main_lex during parsing, and allocate runtime data (execution plan, etc.) during execution.
  • for prepared queries, only to allocate runtime data. The parsed tree itself is reused between executions and thus is stored elsewhere.

◆ mark_used_columns

enum enum_mark_columns THD::mark_used_columns

MARK_COLUMNS_NONE: Means mark_used_columns is not set and no indicator to handler of fields used is set MARK_COLUMNS_READ: Means a bit in read set is set to inform handler that the field is to be read.

Update covering_keys and merge_keys too. MARK_COLUMNS_WRITE: Means a bit is set in write set to inform handler that it needs to update this field in write_row and update_row. MARK_COLUMNS_TEMP: Mark bit in read set, but ignore key sets. Used by filesort().

◆ max_client_packet_length

ulong THD::max_client_packet_length

◆ mdl_context

MDL_context THD::mdl_context

◆ mem_root

MEM_ROOT* THD::mem_root {nullptr}

◆ net

NET THD::net
private

◆ next_to_commit

THD* THD::next_to_commit

Used by MYSQL_BIN_LOG to maintain the commit queue for binary log group commit.

◆ num_truncated_fields

ha_rows THD::num_truncated_fields

◆ open_options

uint THD::open_options

◆ opt_trace

Opt_trace_context THD::opt_trace

optimizer trace of current statement

◆ owned_gtid

Gtid THD::owned_gtid

The GTID of the currently owned transaction.

==== Modes of ownership ====

The following modes of ownership are possible:

  • owned_gtid.sidno==0: the thread does not own any transaction.
  • owned_gtid.sidno==THD::OWNED_SIDNO_ANONYMOUS(==-2): the thread owns an anonymous transaction
  • owned_gtid.sidno>0 and owned_gtid.gno>0: the thread owns a GTID transaction.
  • (owned_gtid.sidno==THD::OWNED_SIDNO_GTID_SET(==-1): this is currently not used. It was reserved for the case where multiple GTIDs are owned (using gtid_next_list). This was one idea to make GTIDs work with NDB: due to the epoch concept, multiple transactions can be combined into one in NDB, and therefore a single transaction on a slave can have multiple GTIDs.)

==== Life cycle of ownership ====

Generally, transaction ownership starts when the transaction is assigned its GTID and ends when the transaction commits or rolls back. On a master (GTID_NEXT=AUTOMATIC), the GTID is assigned just before binlog flush; on a slave (GTID_NEXT=UUID:NUMBER or GTID_NEXT=ANONYMOUS) it is assigned before starting the transaction.

A new client always starts with owned_gtid.sidno=0.

Ownership can be acquired in the following ways:

A1. If GTID_NEXT = 'AUTOMATIC' and GTID_MODE = OFF/OFF_PERMISSIVE: The thread acquires anonymous ownership in gtid_state->generate_automatic_gtid called from MYSQL_BIN_LOG::write_transaction.

A2. If GTID_NEXT = 'AUTOMATIC' and GTID_MODE = ON/ON_PERMISSIVE: The thread generates the GTID and acquires ownership in gtid_state->generate_automatic_gtid called from MYSQL_BIN_LOG::write_transaction.

A3. If GTID_NEXT = 'UUID:NUMBER': The thread acquires ownership in the following ways:

  • In a client, the SET GTID_NEXT statement acquires ownership.
  • The slave's analogy to a clients SET GTID_NEXT statement is Gtid_log_event::do_apply_event. So the slave acquires ownership in this function.

Note: if the GTID UUID:NUMBER is already included in GTID_EXECUTED, then the transaction must be skipped (the GTID auto-skip feature). Thus, ownership is not acquired in this case and owned_gtid.sidno==0.

A4. If GTID_NEXT = 'ANONYMOUS':

- In a client, the SET GTID_NEXT statement acquires ownership.

- In a slave thread, Gtid_log_event::do_apply_event acquires
  ownership.

- Contrary to the case of GTID_NEXT='UUID:NUMBER', it is
  allowed to execute two transactions in sequence without
  changing GTID_NEXT (cf. R1 and R2 below).  Both transactions
  should be executed as anonymous transactions.  But ownership
  is released when the first transaction commits.  Therefore,
  when GTID_NEXT='ANONYMOUS', we also acquire anonymous
  ownership when starting to execute a statement, in
  gtid_reacquire_ownership_if_anonymous called from
  gtid_pre_statement_checks (usually called from
  mysql_execute_command).

A5. Slave applier threads start in a special mode, having GTID_NEXT='NOT_YET_DETERMINED'. This mode cannot be set in a regular client. When GTID_NEXT=NOT_YET_DETERMINED, the slave thread is postponing the decision of the value of GTID_NEXT until it has more information. There are three cases:

  • If the first transaction of the relay log has a Gtid_log_event, then it will set GTID_NEXT=GTID:NUMBER and acquire GTID ownership in Gtid_log_event::do_apply_event.
  • If the first transaction of the relay log has a Anonymous_gtid_log_event, then it will set GTID_NEXT=ANONYMOUS and acquire anonymous ownership in Gtid_log_event::do_apply_event.
  • If the relay log was received from a pre-5.7.6 master with GTID_MODE=OFF (or a pre-5.6 master), then there are neither Gtid_log_events nor Anonymous_log_events in the relay log. In this case, the slave sets GTID_NEXT=ANONYMOUS and acquires anonymous ownership when executing a Query_log_event (Query_log_event::do_apply_event calls dispatch_sql_command which calls gtid_pre_statement_checks which calls gtid_reacquire_ownership_if_anonymous).

Ownership is released in the following ways:

R1. A thread that holds GTID ownership releases ownership at transaction commit or rollback. If GTID_NEXT=AUTOMATIC, all is fine. If GTID_NEXT=UUID:NUMBER, the UUID:NUMBER cannot be used for another transaction, since only one transaction can have any given GTID. To avoid the user mistake of forgetting to set back GTID_NEXT, on commit we set thd->variables.gtid_next.type=UNDEFINED_GTID. Then, any statement that user tries to execute other than SET GTID_NEXT will generate an error.

R2. A thread that holds anonymous ownership releases ownership at transaction commit or rollback. In this case there is no harm in leaving GTID_NEXT='ANONYMOUS', so thd->variables.gtid_next.type will remain ANONYMOUS_GTID and not UNDEFINED_GTID.

There are statements that generate multiple transactions in the binary log. This includes the following:

M1. DROP TABLE that is used with multiple tables, and the tables belong to more than one of the following groups: non-temporary table, temporary transactional table, temporary non-transactional table. DROP TABLE is split into one transaction for each of these groups of tables.

M2. DROP DATABASE that fails e.g. because rmdir fails. Then a single DROP TABLE is generated, which lists all tables that were dropped before the failure happened. But if the list of tables is big, and grows over a limit, the statement will be split into multiple statements.

M3. CREATE TABLE ... SELECT that is logged in row format. Then the server generates a single CREATE statement, followed by a BEGIN ... row events ... COMMIT transaction.

M4. A statement that updates both transactional and non-transactional tables in the same statement, and is logged in row format. Then it generates one transaction for the non-transactional row updates, followed by one transaction for the transactional row updates.

M5. CALL is executed as multiple transactions and logged as multiple transactions.

The general rules for multi-transaction statements are:

  • If GTID_NEXT=AUTOMATIC and GTID_MODE=ON or ON_PERMISSIVE, one GTID should be generated for each transaction within the statement. Therefore, ownership must be released after each commit so that a new GTID can be generated by the next transaction. Typically mysql_bin_log.commit() is called to achieve this. (Note that some of these statements are currently disallowed when GTID_MODE=ON.)
  • If GTID_NEXT=AUTOMATIC and GTID_MODE=OFF or OFF_PERMISSIVE, one Anonymous_gtid_log_event should be generated for each transaction within the statement. Similar to the case above, we call mysql_bin_log.commit() and release ownership between transactions within the statement.

    This works for all the special cases M1-M5 except M4. When a statement writes both non-transactional and transactional updates to the binary log, both the transaction cache and the statement cache are flushed within the same call to flush_thread_caches(THD) from within the binary log group commit code. At that point we cannot use mysql_bin_log.commit(). Instead we release ownership using direct calls to gtid_state->release_anonymous_ownership() and thd->clear_owned_gtids() from binlog_cache_mngr::flush.

  • If GTID_NEXT=ANONYMOUS, anonymous ownership must be preserved between transactions within the statement, to prevent that a concurrent SET GTID_MODE=ON makes it impossible to log the statement. To avoid that ownership is released if mysql_bin_log.commit() is called, we set thd->is_commit_in_middle_of_statement before calling mysql_bin_log.commit. Note that we must set this flag only if GTID_NEXT=ANONYMOUS, not if the transaction is anonymous when GTID_NEXT=AUTOMATIC and GTID_MODE=OFF.

    This works for all the special cases M1-M5 except M4. When a statement writes non-transactional updates in the middle of a transaction, but keeps some transactional updates in the transaction cache, then it is not easy to know at the time of calling mysql_bin_log.commit() whether anonymous ownership needs to be preserved or not. Instead, we directly check if the transaction cache is nonempty before releasing anonymous ownership inside Gtid_state::update_gtids_impl.

  • If GTID_NEXT='UUID:NUMBER', it is impossible to log a multi-transaction statement, since each GTID can only be used by one transaction. Therefore, an error must be generated in this case. Errors are generated in different ways for the different statement types:
    • DROP TABLE: we can detect the situation before it happens, since the table type is known once the tables are opened. So we generate an error before even executing the statement.
    • DROP DATABASE: we can't detect the situation until it is too late; the tables have already been dropped and we cannot log anything meaningful. So we don't log at all.
    • CREATE TABLE ... SELECT: this is not allowed when enforce_gtid_consistency is ON; the statement will be forbidden in is_ddl_gtid_compatible.
    • Statements that update both transactional and non-transactional tables are disallowed when GTID_MODE=ON, so this normally does not happen. However, it can happen if the slave uses a different engine type than the master, so that a statement that updates InnoDB+InnoDB on master updates InnoDB+MyISAM on slave. In this case the statement will be forbidden in is_dml_gtid_compatible and will not be allowed to execute.
    • CALL: the second statement will generate an error because GTID_NEXT is 'undefined'. Note that this situation can only happen if user does it on purpose: A CALL on master is logged as multiple statements, so a slave never executes CALL with GTID_NEXT='UUID:NUMBER'.

Finally, ownership release is suppressed in one more corner case:

C1. Administration statements including OPTIMIZE TABLE, REPAIR TABLE, or ANALYZE TABLE are written to the binary log even if they fail. This means that the thread first calls trans_rollack, and then writes the statement to the binlog. Rollback normally releases ownership. But ownership must be kept until writing the binlog. The solution is that these statements set thd->skip_gtid_rollback=true before calling trans_rollback, and Gtid_state::update_on_rollback does not release ownership if the flag is set.

◆ OWNED_SIDNO_ANONYMOUS

const int THD::OWNED_SIDNO_ANONYMOUS = -2
static

◆ OWNED_SIDNO_GTID_SET

const int THD::OWNED_SIDNO_GTID_SET = -1
static

◆ owned_tsid

mysql::gtid::Tsid THD::owned_tsid

For convenience, this contains the TSID component of the GTID stored in owned_gtid.

◆ packet

String THD::packet
private

◆ parsing_system_view

bool THD::parsing_system_view

◆ password

uchar THD::password

◆ peer_port

uint16 THD::peer_port

◆ previous_found_rows

ulonglong THD::previous_found_rows

Stores the result of the FOUND_ROWS() function.

Set at query end, stable throughout the query.

◆ profiling

std::unique_ptr<PROFILING> THD::profiling

◆ protocol_binary

std::unique_ptr<Protocol_binary> THD::protocol_binary

◆ protocol_text

std::unique_ptr<Protocol_text> THD::protocol_text

◆ query_id

query_id_t THD::query_id

◆ query_name_consts

uint THD::query_name_consts

number of name_const() substitutions, see sp_head.cc:subst_spvars()

◆ query_plan

class THD::Query_plan THD::query_plan

◆ query_start_usec_used

bool THD::query_start_usec_used

◆ rand

struct rand_struct THD::rand

◆ rand_saved_seed1

ulong THD::rand_saved_seed1

◆ rand_saved_seed2

ulong THD::rand_saved_seed2

◆ rand_used

bool THD::rand_used

◆ real_id

my_thread_t THD::real_id

◆ rli_fake

Relay_log_info* THD::rli_fake

◆ rli_slave

Relay_log_info* THD::rli_slave

◆ rpl_thd_ctx

Rpl_thd_context THD::rpl_thd_ctx

◆ running_explain_analyze

bool THD::running_explain_analyze = false

Whether we are currently in the execution phase of an EXPLAIN ANALYZE query.

If so, send_kill_message() won't actually set an error; we will add a warning near the end of the execution instead.

◆ scheduler

thd_scheduler THD::scheduler

◆ scramble

char THD::scramble[SCRAMBLE_LENGTH+1]

◆ server_id

uint32 THD::server_id

◆ server_status

uint THD::server_status

◆ session_sysvar_res_mgr

Session_sysvar_resource_manager THD::session_sysvar_res_mgr

◆ session_tracker

Session_tracker THD::session_tracker

◆ skip_gtid_rollback

bool THD::skip_gtid_rollback

◆ skip_readonly_check

bool THD::skip_readonly_check
private

◆ skip_transaction_read_only_check

bool THD::skip_transaction_read_only_check
private

◆ slave_thread

bool THD::slave_thread

◆ sp_func_cache

sp_cache* THD::sp_func_cache

◆ sp_proc_cache

sp_cache* THD::sp_proc_cache

◆ sp_runtime_ctx

sp_rcontext* THD::sp_runtime_ctx

Current SP-runtime context.

◆ start_time

struct timeval THD::start_time

◆ start_utime

ulonglong THD::start_utime

Query start time, expressed in microseconds.

◆ statement_id_counter

ulong THD::statement_id_counter

◆ status_var

struct System_status_var THD::status_var

◆ status_var_aggregated

bool THD::status_var_aggregated

◆ stmt_arena

Query_arena* THD::stmt_arena

◆ stmt_depends_on_first_successful_insert_id_in_prev_stmt

bool THD::stmt_depends_on_first_successful_insert_id_in_prev_stmt

◆ stmt_map

Prepared_statement_map THD::stmt_map

All prepared statements of this connection.

◆ 

union { ... } THD::sys_var_tmp

◆ system_thread

enum enum_thread_type THD::system_thread

◆ table_map_for_update

table_map THD::table_map_for_update

◆ thd_tx_priority

int THD::thd_tx_priority

◆ thread_specific_used

bool THD::thread_specific_used

is set if some thread specific value(s) used in a statement.

◆ thread_stack

const char* THD::thread_stack

◆ time_zone_used

bool THD::time_zone_used

◆ timer

struct THD_timer_info* THD::timer

Holds active timer object.

◆ timer_cache

struct THD_timer_info* THD::timer_cache

After resetting(cancelling) timer, current timer object is cached with timer_cache timer to reuse.

◆ tmp_table

uint THD::tmp_table

◆ tmp_table_seq_id

uint THD::tmp_table_seq_id
private

Sequential number of internal tmp table created in the statement.

Useful for tracking tmp tables when number of them is involved in a query.

◆ transaction_rollback_request

bool THD::transaction_rollback_request

Set by a storage engine to request the entire transaction (that possibly spans multiple engines) to rollback.

Reset in ha_rollback.

◆ tx_commit_pending

bool THD::tx_commit_pending

◆ tx_isolation

enum_tx_isolation THD::tx_isolation

◆ tx_priority

int THD::tx_priority

◆ tx_read_only

bool THD::tx_read_only

◆ ull_hash

malloc_unordered_map<std::string, User_level_lock *> THD::ull_hash
Initial value:
{
PSI_memory_key key_memory_User_level_lock
Definition: psi_memory_key.cc:97

◆ ulong_value

ulong THD::ulong_value

◆ ulonglong_value

ulonglong THD::ulonglong_value

◆ unioned_events

bool THD::unioned_events

◆ unioned_events_trans

bool THD::unioned_events_trans

◆ unmasked_server_id

uint32 THD::unmasked_server_id

◆ update_lock_default

thr_lock_type THD::update_lock_default

Type of lock to be used for all DML statements, except INSERT, in cases when lock is not specified explicitly.

Set to TL_WRITE or TL_WRITE_LOW_PRIORITY depending on whether low_priority_updates option is off or on.

◆ user_time

struct timeval THD::user_time

◆ user_var_events

Prealloced_array<Binlog_user_var_event *, 2> THD::user_var_events

◆ user_var_events_alloc

MEM_ROOT* THD::user_var_events_alloc

◆ user_vars

Hash for user variables.

User variables are per session, but can also be monitored outside of the session, so a lock is needed to prevent race conditions. Protected by LOCK_thd_data.

◆ variables [1/2]

System_variables THD::variables

◆ variables [2/2]

struct System_variables THD::variables

◆ waiting_for_disk_space

bool THD::waiting_for_disk_space = false
private

◆ want_privilege

Access_bitmask THD::want_privilege

Used by Item::check_column_privileges() to tell which privileges to check for.

Set to ~0ULL before starting to resolve a statement. Set to desired privilege mask before calling a resolver function that will call Item::check_column_privileges(). After use, restore previous value as current value.

◆ where

const char* THD::where

◆ work_part_info

partition_info* THD::work_part_info

The documentation for this class was generated from the following files: