MySQL 8.4.3
Source Code Documentation
|
For each client connection we create a separate thread with THD serving as a thread/connection descriptor. More...
#include <sql_lexer_thd.h>
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 Member Functions | |
const CHARSET_INFO * | charset () 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_client * | dd_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_context * | secondary_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_context * | security_context () const |
void | set_security_context (Security_context *sctx) |
const Protocol * | get_protocol () const |
Protocol * | get_protocol () |
SSL_handle | get_ssl () const |
const Protocol_classic * | get_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_classic * | get_protocol_classic () |
const LEX_CSTRING & | catalog () 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_data * | get_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_event * | binlog_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_event * | binlog_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 NET * | get_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_ctx * | get_transaction () |
const Transaction_ctx * | get_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_CONN * | get_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... | |
THD * | get_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_INFO * | collation () |
Time_zone * | time_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_area * | get_stmt_da () |
Returns first Diagnostics Area for the current statement. More... | |
const Diagnostics_area * | get_stmt_da () const |
Returns first Diagnostics Area for the current statement. More... | |
const Diagnostics_area * | get_stacked_da () const |
Returns the second Diagnostics Area for the current statement. More... | |
Diagnostics_area * | get_parser_da () |
Returns thread-local Diagnostics Area for parsing. More... | |
Diagnostics_area * | get_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_INFO * | charset () 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_set * | get_gtid_next_list () |
Return the value of @gtid_next_list: either a Gtid_set or NULL. More... | |
const Gtid_set * | get_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_CSTRING & | db () 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_ctx * | resource_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_thread * | get_psi () const |
Read the performance schema thread instrumentation associated with this user session. More... | |
const Internal_error_handler * | get_internal_handler () const |
void | push_internal_handler (Internal_error_handler *handler) |
Add an internal error handler to the thread execution context. More... | |
Internal_error_handler * | pop_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_CSTRING & | query () 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 String & | rewritten_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_server * | cost_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_int * | get_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 |
Item * | item_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_observer * | get_reprepare_observer () const |
void | push_reprepare_observer (Reprepare_observer *o) |
Reprepare_observer * | pop_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 () |
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_condition * | raise_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< LEX > | main_lex |
The lex to hold the parsed tree of conventional (non-prepared) queries. More... | |
std::unique_ptr< dd::cache::Dictionary_client > | m_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_context > | m_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... | |
Protocol * | m_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_HA > | ha_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_ctx > | m_transaction |
Attachable_trx * | m_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_CONN * | m_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_handler * | m_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_area * | m_query_rewrite_plugin_da_ptr |
Diagnostics_area * | m_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_int * | m_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_cache * | events_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... | |
For each client connection we create a separate thread with THD serving as a thread/connection descriptor.
using THD::Se_GTID_flagset = std::bitset<SE_GTID_MAX> |
using THD::sql_mode_t = uint64_t |
enum THD::Commit_error |
enum THD::enum_reset_lex |
|
private |
Represents life cycle stages of THD instance.
Stage transition in THD clean up:
Stage transition in THD disposal:
Enumerator | |
---|---|
ACTIVE | |
ACTIVE_AND_CLEAN | |
SCHEDULED_FOR_DISPOSAL | |
CLEANED_UP | |
RESOURCES_RELEASED | |
DISPOSED |
enum THD::killed_state |
enum THD::Se_GTID_flag : size_t |
SE GTID persistence flag types.
|
explicit |
|
override |
bool THD::add_external | ( | unsigned int | slot, |
void * | data | ||
) |
|
inline |
void THD::awake | ( | THD::killed_state | state_to_set | ) |
Awake a thread.
[in] | state_to_set | value for THD::killed |
This is normally called from another thread's THD object.
|
inline |
Copy ha_data into the provided argument.
Used by Attachble_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).
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.
|
inline |
|
inline |
|
inline |
Record a transient change to a pointer to an Item within another Item.
|
inline |
|
inline |
|
inline |
Check if clone network Vio is active.
bool THD::check_event_subscribers | ( | Event_tracking_class | event, |
unsigned long | subevent, | ||
bool | check_audited | ||
) |
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.
|
private |
|
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.
void THD::cleanup_after_query | ( | ) |
void THD::cleanup_connection | ( | void | ) |
|
inline |
|
inline |
|
inline |
|
inline |
Clear clone network Vio for remote clone.
|
inline |
Clear copy of the status variables.
|
inline |
Clear the query costs attributes for the current query.
|
inline |
|
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.
|
inline |
Cleared after flushing SE logs during binlog reset.
void THD::clear_next_event_pos | ( | ) |
|
inline |
|
inline |
|
inline |
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 |
|
inline |
|
inline |
Copy status variables into a structure pointed by the specified pointer and keep track of the pointer internally.
dst_var | status variable structure pointer, where internal status variables are copied into. |
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:
This is useful to execute an isolated, internal THD session to access tables, while leaving tables in the parent session unchanged.
thd | parent session |
const Cost_model_server * THD::cost_model | ( | ) | const |
Retrieve the optimizer cost model for this connection.
|
inline |
|
inline |
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.
void THD::decrement_user_connections_counter | ( | ) |
void THD::disable_low_level_commit_ordering | ( | ) |
Enables ordering in ha_commit_low.
Used in binlog::commit
|
inline |
void THD::disconnect | ( | bool | server_shutdown = false | ) |
Disconnect the associated communication endpoint.
Close the Vio associated this session.
void THD::enable_low_level_commit_ordering | ( | ) |
Enables ordering in ha_commit_low.
Used in binlog::commit
|
inline |
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.
void THD::end_statement | ( | ) |
|
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().
cond | the condition to wait on | |
mutex | the associated mutex | |
[in] | stage | the stage to enter, or NULL |
[out] | old_stage | the previous stage, or NULL |
src_function | function name of the caller | |
src_file | file name of the caller | |
src_line | line number of the caller |
Implements MDL_context_owner.
|
inline |
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 | ||
) |
bool THD::event_notify | ( | struct st_mysql_event_generic * | event_data | ) |
|
inlineoverridevirtual |
End a wait on a condition.
[in] | stage | the new stage to enter |
src_function | function name of the caller | |
src_file | file name of the caller | |
src_line | line number of the caller |
Implements MDL_context_owner.
|
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().
void * THD::fetch_external | ( | unsigned int | slot | ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void THD::get_definer | ( | LEX_USER * | definer | ) |
|
inline |
|
inline |
|
inline |
Return the value of @gtid_next_list: either a Gtid_set or NULL.
|
inline |
Return the value of @gtid_next_list: either a Gtid_set or NULL.
|
inline |
Retrieve Ha_data for a given slot.
Each handler has a fixed slot nr.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
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.
|
inline |
Returns the plugin, the thd belongs to.
Protocol * THD::get_protocol | ( | ) |
|
inline |
Protocol_classic * THD::get_protocol_classic | ( | ) |
|
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
|
inline |
Read the performance schema thread instrumentation associated with this user session.
This method is safe to use from a different thread.
|
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.
|
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.
|
inline |
|
inline |
|
inline |
|
inline |
Returns the second Diagnostics Area for the current statement.
|
inline |
Returns first Diagnostics Area for the current statement.
|
inline |
Returns first Diagnostics Area for the current statement.
|
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).
Implements MDL_context_owner.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
enum_vio_type THD::get_vio_type | ( | ) | const |
|
private |
Handle a sql condition.
sql_errno | the condition error number |
sqlstate | the condition sqlstate |
level | the condition level |
msg | the condition message text |
|
inline |
|
inline |
true if the session is in a multi-statement transaction mode (
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.
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
|
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.
void THD::inc_examined_row_count | ( | ha_rows | count | ) |
void THD::inc_lock_usec | ( | ulonglong | usec | ) |
void THD::inc_sent_row_count | ( | ha_rows | count | ) |
void THD::inc_status_created_tmp_disk_tables | ( | ) |
void THD::inc_status_created_tmp_tables | ( | ) |
void THD::inc_status_select_full_join | ( | ) |
void THD::inc_status_select_full_range_join | ( | ) |
void THD::inc_status_select_range | ( | ) |
void THD::inc_status_select_range_check | ( | ) |
void THD::inc_status_select_scan | ( | ) |
void THD::inc_status_sort_merge_passes | ( | ) |
void THD::inc_status_sort_range | ( | ) |
void THD::inc_status_sort_rows | ( | ha_rows | count | ) |
void THD::inc_status_sort_scan | ( | ) |
void THD::increment_con_per_hour_counter | ( | ) |
void THD::increment_questions_counter | ( | ) |
void THD::increment_updates_counter | ( | ) |
void THD::increment_user_connections_counter | ( | ) |
|
private |
void THD::init_cost_model | ( | ) |
Initialize the optimizer cost model.
This function should be called each time a new query is started.
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.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
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.
|
inline |
The function checks whether the thread is processing queries from binlog, as automatically generated by mysqlbinlog.
|
inline |
bool THD::is_classic_protocol | ( | ) | const |
|
private |
|
inline |
|
inline |
|
finalvirtual |
Return false if connection to client is broken.
Implements MDL_context_owner.
|
inline |
Returns if the user of the session has the CONNECTION_ADMIN privilege or not.
true | User has CONNECTION_ADMIN privilege |
false | Otherwise |
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:
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.
true | The binary log is currently disabled for the statement. |
false | The binary log is currently enabled for the statement. |
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.
true | binlog local caches are empty or disabled and binlogging is enabled |
false | binlog local caches are enabled and contain data or binlogging is disabled |
|
inline |
Determine the binlog format of the current statement.
0 | if the current statement will be logged in statement format. |
nonzero | if the current statement will be logged in row format. |
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.
true | The binary log is currently disabled for the statement. |
false | The binary log is currently enabled for the statement. |
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.
true | if is enable |
false | otherwise |
|
inline |
bool THD::is_engine_ha_data_detached | ( | ) | const |
rpl_detach_engine_ha_data
.
|
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().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinefinalvirtual |
Has the owner thread been killed?
Implements MDL_context_owner.
|
inline |
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
|
inline |
bool THD::is_one_phase_commit | ( | ) |
|
inline |
|
inlineprivatedelete |
|
inline |
bool THD::is_secondary_storage_engine_eligible | ( | ) | const |
Checks if queries in this session can use a secondary storage engine for execution.
|
inline |
|
privatedelete |
|
privatedelete |
|
privatedelete |
|
inline |
|
inline |
|
inline |
Returns if the user of the session has the SYSTEM_USER privilege or not.
true | User has SYSTEM_USER privilege |
false | Otherwise |
|
inline |
Returns the current waiting_for_disk_space flag value.
void THD::leave_locked_tables_mode | ( | ) |
Leave explicit LOCK TABLES or prelocked mode and restore value of transaction sentinel in MDL subsystem.
|
inline |
Locks the query plan of this THD.
|
inline |
|
inline |
void THD::mark_transaction_to_rollback | ( | bool | all | ) |
Mark transaction to rollback and mark error as fatal to a sub-statement.
all | true <=> rollback main transaction. |
|
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.
Implements MDL_context_owner.
|
inline |
Remember that place was updated with new_value so it can be restored by rollback_item_tree_changes().
[in] | place | the location that will change, and whose old value we need to remember for restoration |
[in] | new_value | new value about to be inserted into *place |
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.
|
overridevirtual |
Notify interested storage engines that we have just released exclusive lock for the key.
Implements MDL_context_owner.
|
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.
Implements MDL_context_owner.
|
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.
ctx_in_use | The MDL context owner (thread) to wake up. |
needs_thr_lock_abort | Indicates that to wake up thread this call needs to abort its waiting on table-level lock. |
Implements MDL_context_owner.
|
inline |
Tells whether the given optimizer_switch flag is on.
|
inline |
|
inline |
Defer freeing owned GTID and TSID till unpinned.
|
inline |
Pop the top DA off the Diagnostics Area stack.
|
private |
Internal_error_handler * THD::pop_internal_handler | ( | ) |
Remove the error handler last pushed.
|
inline |
void THD::pop_protocol | ( | ) |
Pops the top protocol of the Protocol stack and sets the previous one as the current protocol.
|
inline |
|
private |
Return the m_proc_info, possibly using the string of an older server release, according to @terminology_use_previous.
sysvars | Use the value of @terminology_use_previous stored in this System_variables object. |
|
inline |
Return the m_proc_info, possibly using the string of an older server release, according to @session.terminology_use_previous.
invoking_thd | Use @session.terminology_use_previous of this session. |
|
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.
da | Diagnostics Area to be come the top of the Diagnostics Area stack. |
copy_conditions | Copy the conditions from the new second Diagnostics Area to the new first Diagnostics Area, as per SQL standard. |
|
private |
void THD::push_internal_handler | ( | Internal_error_handler * | handler | ) |
Add an internal error handler to the thread execution context.
handler | the exception handler to add |
|
inline |
|
inline |
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.
protocol | Protocol to be inserted. |
|
inline |
|
inline |
my_timeval THD::query_start_timeval_trunc | ( | uint | decimals | ) |
|
private |
Raise a generic SQL condition.
Also calls mysql_event_tracking_general_notify() unless the condition is handled by a SQL condition handler.
sql_errno | the condition error number |
sqlstate | the condition SQLSTATE |
level | the condition level |
msg | the condition message text |
fatal_error | should the fatal_error flag be set? |
void THD::raise_error | ( | uint | code | ) |
Raise an exception condition.
code | the MYSQL_ERRNO error code of the error |
void THD::raise_error_printf | ( | uint | code, |
... | |||
) |
Raise an exception condition, with a formatted message.
code | the MYSQL_ERRNO error code of the error |
void THD::raise_note | ( | uint | code | ) |
Raise a completion condition (note), with a fixed message.
code | the MYSQL_ERRNO error code of the note |
void THD::raise_note_printf | ( | uint | code, |
... | |||
) |
Raise an completion condition (note), with a formatted message.
code | the MYSQL_ERRNO error code of the note |
void THD::raise_warning | ( | uint | code | ) |
Raise a completion condition (warning).
code | the MYSQL_ERRNO error code of the warning |
void THD::raise_warning_printf | ( | uint | code, |
... | |||
) |
Raise a completion condition (warning), with a formatted message.
code | the MYSQL_ERRNO error code of the warning |
|
inline |
|
inline |
|
inline |
void THD::release_external_store | ( | ) |
void THD::release_resources | ( | ) |
Release most resources, prior to THD destruction.
bool THD::release_resources_done | ( | ) | const |
|
inline |
Request SE to persist GTID explicitly.
|
inline |
|
inline |
Copy status variables into a structure pointed by the specified pointer passed into copy_status_var method call.
|
inline |
|
inline |
Set the current database; use shallow copy of C-string.
new_db | the new database name. |
|
inline |
|
inline |
Reset by SE at transaction end after persisting GTID.
void THD::reset_n_backup_open_tables_state | ( | Open_tables_backup * | backup, |
uint | add_state_flags | ||
) |
|
inline |
|
inline |
Reset query string to be displayed in PFS.
Also reset the safety flag for information_schema.process_list for next query.
|
inline |
Reset thd->m_rewritten_query.
Protected with the LOCK_thd_query mutex.
|
inline |
|
inline |
void THD::reset_sub_statement_state | ( | Sub_statement_state * | backup, |
uint | new_state | ||
) |
|
inline |
Get resource group context.
void THD::restore_backup_open_tables_state | ( | Open_tables_backup * | backup | ) |
void THD::restore_globals | ( | ) |
|
inline |
Restore ha_data from the provided backup copy.
Used by Attachable_Transaction.
void THD::restore_sub_statement_state | ( | Sub_statement_state * | backup | ) |
|
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!
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.
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.
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.
|
inline |
|
inline |
Save the current query costs attributes in the thread session status.
Use this method only after the query execution is completed, so that
actually reports the previous query, not itself.
|
inline |
|
inline |
|
inline |
Can secondary storage engines be used for query execution in this session?
|
inline |
|
inline |
int THD::send_explain_fields | ( | Query_result * | result | ) |
void THD::send_kill_message | ( | ) | const |
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.
list | List of items to send to client |
flags | Bit mask with the following functions:
|
false | ok |
true | Error (Note that in this case the error is not sent to the client) |
bool THD::send_result_set_row | ( | const mem_root_deque< Item * > & | row_items | ) |
Send one result set row.
row_items | a collection of column values for that row |
true | Error. |
false | Success. |
void THD::send_statement_status | ( | ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Set active clone network Vio for remote clone.
[in] | vio | network vio |
void THD::set_command | ( | enum enum_server_command | command | ) |
|
inline |
Sets the connection_admin flag atomically for the current session.
[in] | connection_admin_flag | boolean flag that indicates value to set. |
|
inline |
|
inline |
bool THD::set_db | ( | const LEX_CSTRING & | new_db | ) |
Set the current database; use deep copy of C-string.
new_db | the 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).
false | Success |
true | Out-of-memory error |
|
inline |
Set by SE when it guarantees GTID persistence.
|
inline |
|
inline |
Assign a new value to is_killable Protected with the LOCK_thd_data mutex.
|
inline |
Set when binlog reset operation is started.
void THD::set_new_thread_id | ( | ) |
Assign a value to m_thread_id by calling Global_THD_manager::get_new_thread_id().
void THD::set_next_event_pos | ( | const char * | _filename, |
ulonglong | _pos | ||
) |
|
inline |
Assign a new value to open_tables.
Protected with the LOCK_thd_data mutex.
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.
|
inline |
Sets the plugin id to the value provided as parameter.
plugin | the id of the plugin the thd belongs to |
|
inline |
|
inline |
Save the performance schema thread instrumentation associated with this user session.
psi | Performance schema thread instrumentation |
|
inline |
Assign a new value to thd->m_query_string.
Protected with the LOCK_thd_query mutex.
void THD::set_query | ( | LEX_CSTRING | query_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.
|
inline |
Assign a new value to thd->query_id.
Protected with the LOCK_thd_data mutex.
|
inline |
|
inline |
Set if the query string to be safe to display.
[in] | safe | if it is safe to display query string |
|
inline |
Indicate whether secondary storage engine is forced for this execution.
|
inline |
Enables or disables use of secondary storage engines in this session.
void THD::set_secondary_engine_statement_context | ( | std::unique_ptr< Secondary_engine_statement_context > | context | ) |
|
inline |
void THD::set_sent_row_count | ( | ha_rows | count | ) |
|
inline |
|
inline |
|
inline |
|
inline |
void THD::set_status_no_good_index_used | ( | ) |
void THD::set_status_no_index_used | ( | ) |
|
inline |
Sets the system_user flag atomically for the current session.
[in] | system_user_flag | boolean flag that indicates value to set. |
void THD::set_time | ( | ) |
|
inline |
|
inline |
|
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.
void THD::set_transaction | ( | Transaction_ctx * | transaction_ctx | ) |
Changes the Transaction_ctx instance within THD-object.
The previous Transaction_ctx instance is destroyed.
transaction_ctx | new Transaction_ctx instance to be associated with the THD-object. |
void THD::set_user_connect | ( | USER_CONN * | uc | ) |
|
inline |
Set the waiting_for_disk_space flag.
waiting | The value to set in the flag. |
void THD::shutdown_active_vio | ( | ) |
void THD::shutdown_clone_vio | ( | ) |
Shutdown clone vio, if active.
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.
|
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.
void THD::store_globals | ( | ) |
|
inline |
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!
query_arg | The 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. |
|
inline |
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.
format | Error format message. NULL means ER(ER_SYNTAX_ERROR). |
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.
mysql_errno | Error number to get a format string with ER_THD(). |
|
inline |
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.
location | YYSTYPE object: error position. |
format | Error format message. NULL means ER(ER_SYNTAX_ERROR). |
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.
location | YYSTYPE object: error position |
mysql_errno | Error number to get a format string with ER_THD() |
|
inline |
void THD::time_out_user_resource_limits | ( | ) |
|
inline |
|
inline |
|
inline |
Unpin and free GTID and TSID.
void THD::update_charset | ( | ) |
|
inline |
void THD::update_slow_query_status | ( | ) |
Evaluate the current time, and if it exceeds the long-query-time setting, mark the query as slow.
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.
pos_in_lexer_raw_buffer | Pointer into LEX::m_buf or NULL. |
format | An error message format string. |
args | Arguments to the format string. |
void THD::vsyntax_error_at | ( | const POS & | location, |
const char * | format, | ||
va_list | args | ||
) |
|
friend |
All global error messages are sent here where the first one is stored for the client.
|
friend |
|
friend |
Push the warning to error list if there is still room in the list.
thd | Thread handle |
severity | Severity of warning (note, warning) |
code | Error number |
message_text | Clear error message |
|
friend |
|
friend |
|
friend |
bool THD::arg_of_last_insert_id_function |
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.
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.
|
private |
Discrete_intervals_list THD::auto_inc_intervals_forced |
Discrete_intervals_list THD::auto_inc_intervals_in_cur_stmt_for_binlog |
PS_PARAM* THD::bind_parameter_values |
The parameter value bindings for the current query.
Allocated on the THD memroot. Can be empty
unsigned long THD::bind_parameter_values_count |
the number of elements in parameters
|
private |
struct { ... } THD::binlog_evt_union |
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.
rpl_event_coordinates THD::binlog_next_event_pos |
uchar* THD::binlog_row_event_extra_data |
|
private |
|
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 THD::bool_value |
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:
bool THD::charset_is_character_set_filesystem |
bool THD::charset_is_collation_connection |
bool THD::charset_is_system_charset |
is set if a statement accesses a temporary table created through CREATE TEMPORARY TABLE.
enum_check_fields THD::check_for_truncated_fields |
enum THD::Commit_error THD::commit_error |
mysql_cond_t THD::COND_group_replication_connection_cond_var |
mysql_cond_t THD::COND_thr_lock |
Condition variable used for waiting by the THR_LOCK.c subsystem.
ulonglong THD::conn_mem_alloc_number |
struct System_status_var* THD::copy_status_var_ptr |
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.
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.
const char* THD::current_key_name |
std::atomic<mysql_mutex_t *> THD::current_mutex |
The mutex used with current_cond.
|
private |
Indicates the format in which the current statement will be logged.
This can only be set from decide_logging_format()
.
const CHARSET_INFO* THD::db_charset |
uint THD::dbug_sentry |
XID THD::debug_binlog_xid_last |
|
static |
bool THD::derived_tables_processing |
bool THD::do_union |
double THD::double_value |
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.
enum durability_properties THD::durability_property |
bool THD::enable_slow_log |
|
private |
|
private |
|
private |
uint32 THD::file_id |
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.
uint THD::fill_variables_recursion_level |
query_id_t THD::first_query_id |
ulonglong THD::first_successful_insert_id_in_cur_stmt |
ulonglong THD::first_successful_insert_id_in_prev_stmt |
ulonglong THD::first_successful_insert_id_in_prev_stmt_for_binlog |
bool THD::for_debug_only_is_set_persist_options {false} |
Global_read_lock THD::global_read_lock |
|
private |
collation_unordered_map<std::string, unique_ptr_my_free<Table_ref> > THD::handler_tables_hash |
bool THD::has_gtid_consistency_violation |
bool THD::has_incremented_gtid_automatic_count |
Flag indicating whether this session incremented the number of sessions with GTID_NEXT set to AUTOMATIC:tag.
bool THD::in_loadable_function {false} |
bool THD::in_lock_tables |
uint THD::in_sub_stmt |
struct System_status_var* THD::initial_status_var |
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.
|
private |
Variable to mark if the object is part of a Srv_session object, which aggregates THD.
bool THD::is_commit_in_middle_of_statement |
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
bool THD::is_killable |
bool THD::is_mem_cnt_error_issued |
bool THD::is_operating_gtid_table_implicitly |
bool THD::is_operating_substatement_implicitly |
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.
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.
std::atomic<killed_state> THD::killed |
LEX* THD::lex |
mysql_mutex_t THD::LOCK_current_cond |
Mutex protecting access to current_mutex and current_cond.
mysql_mutex_t THD::LOCK_group_replication_connection_mutex |
THR_LOCK_INFO THD::lock_info |
|
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).
mysql_mutex_t THD::LOCK_thd_data |
Protects THD data accessed from other threads.
The attributes protected are:
mysql_mutex_t THD::LOCK_thd_protocol |
Protects THD::m_protocol when it gets removed in x plugin.
mysql_mutex_t THD::LOCK_thd_query |
Protects THD::m_query_string.
No other mutexes should be locked while having this mutex locked.
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.
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 THD::locked_tables_list |
long THD::long_value |
|
private |
bool THD::m_audited |
|
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.*
|
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.
|
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.
|
private |
Currently selected catalog.
|
private |
Type of current query: COM_STMT_PREPARE, COM_QUERY, etc.
Set from first byte of the packet in do_command()
std::vector<char> THD::m_connection_attributes |
Session's connection attributes for the connected client.
|
private |
Optimizer cost model for server operations.
|
private |
double THD::m_current_query_cost |
Current query cost.
ulonglong THD::m_current_query_partial_plans |
Current query partial plans.
|
private |
|
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.
|
private |
sql_digest_state* THD::m_digest |
Current statement digest.
sql_digest_state THD::m_digest_state |
Top level statement digest.
bool THD::m_disable_password_validation |
bool THD::m_enable_plugins |
|
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.
PSI_idle_locker* THD::m_idle_psi |
Idle instrumentation.
PSI_idle_locker_state THD::m_idle_state |
Idle instrumentation state.
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.
|
private |
The current internal error handler for this thread, or NULL.
|
private |
|
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.
|
private |
|
private |
Flag that indicates if the user of current session has CONNECTION_ADMIN privilege.
|
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
|
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
|
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.
|
private |
Flag that indicates if the user of current session has SYSTEM_USER privilege.
|
private |
Time spent waiting for TABLE locks and DATA locks.
Expressed in microseconds.
Security_context THD::m_main_security_ctx |
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.
NET_SERVER THD::m_net_server_extension |
Additional network instrumentation for the server only.
|
private |
|
private |
cf.
get_parser_da()
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.
|
private |
Stores the plugin id it is attached to (if any).
|
private |
|
private |
|
private |
Performance schema thread instrumentation for this session.
This member is maintained using atomic operations, do not access it directly.
|
private |
|
private |
|
private |
The query associated with this statement.
|
private |
Resource group context indicating the current resource group and the name of the resource group to switch to during execution of a 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:
|
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_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".
|
private |
Se_GTID_flagset THD::m_se_gtid_flags |
Flags for SE GTID persistence.
|
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.
|
private |
This flag tells if a secondary storage engine can be used to execute a query in this session.
|
private |
Current query's secondary engine statement context.
Security_context* THD::m_security_ctx |
|
private |
Number of rows we actually sent to the client, including "synthetic" rows in ROLLUP etc.
bool THD::m_server_idle |
True if the server code is IDLE for this connection.
|
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.
PSI_stage_progress* THD::m_stage_progress_psi |
Current stage progress instrumentation.
PSI_statement_locker* THD::m_statement_psi |
Current statement instrumentation.
PSI_statement_locker_state THD::m_statement_state |
Current statement instrumentation state.
|
private |
|
private |
|
private |
This counter is 32 bit because of the client protocol.
real_id
for this.unsigned char* THD::m_token_array |
Current statement digest token array.
|
private |
|
private |
|
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.
|
private |
PSI_transaction_locker* THD::m_transaction_psi |
Current transaction instrumentation.
PSI_transaction_locker_state THD::m_transaction_state |
Current transaction instrumentation state.
Transactional_ddl_context THD::m_transactional_ddl {this} |
|
private |
List<Security_context> THD::m_view_ctx_list |
|
private |
|
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. (
|
private |
This memory root is used for two purposes:
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().
ulong THD::max_client_packet_length |
MDL_context THD::mdl_context |
|
private |
THD* THD::next_to_commit |
Used by MYSQL_BIN_LOG to maintain the commit queue for binary log group commit.
ha_rows THD::num_truncated_fields |
uint THD::open_options |
Opt_trace_context THD::opt_trace |
optimizer trace of current statement
Gtid THD::owned_gtid |
The GTID of the currently owned transaction.
==== Modes of ownership ====
The following modes of ownership are possible:
==== 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:
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:
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=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.
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.
|
static |
|
static |
mysql::gtid::Tsid THD::owned_tsid |
For convenience, this contains the TSID component of the GTID stored in owned_gtid.
|
private |
bool THD::parsing_system_view |
uchar THD::password |
uint16 THD::peer_port |
ulonglong THD::previous_found_rows |
Stores the result of the FOUND_ROWS() function.
Set at query end, stable throughout the query.
std::unique_ptr<PROFILING> THD::profiling |
std::unique_ptr<Protocol_binary> THD::protocol_binary |
std::unique_ptr<Protocol_text> THD::protocol_text |
query_id_t THD::query_id |
uint THD::query_name_consts |
number of name_const() substitutions, see sp_head.cc:subst_spvars()
class THD::Query_plan THD::query_plan |
bool THD::query_start_usec_used |
struct rand_struct THD::rand |
ulong THD::rand_saved_seed1 |
ulong THD::rand_saved_seed2 |
bool THD::rand_used |
my_thread_t THD::real_id |
Relay_log_info* THD::rli_fake |
Relay_log_info* THD::rli_slave |
Rpl_thd_context THD::rpl_thd_ctx |
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.
thd_scheduler THD::scheduler |
char THD::scramble[SCRAMBLE_LENGTH+1] |
uint32 THD::server_id |
uint THD::server_status |
Session_sysvar_resource_manager THD::session_sysvar_res_mgr |
Session_tracker THD::session_tracker |
bool THD::skip_gtid_rollback |
|
private |
|
private |
bool THD::slave_thread |
sp_cache* THD::sp_func_cache |
sp_cache* THD::sp_proc_cache |
sp_rcontext* THD::sp_runtime_ctx |
Current SP-runtime context.
struct timeval THD::start_time |
ulonglong THD::start_utime |
Query start time, expressed in microseconds.
ulong THD::statement_id_counter |
struct System_status_var THD::status_var |
bool THD::status_var_aggregated |
Query_arena* THD::stmt_arena |
bool THD::stmt_depends_on_first_successful_insert_id_in_prev_stmt |
Prepared_statement_map THD::stmt_map |
All prepared statements of this connection.
union { ... } THD::sys_var_tmp |
enum enum_thread_type THD::system_thread |
table_map THD::table_map_for_update |
int THD::thd_tx_priority |
bool THD::thread_specific_used |
is set if some thread specific value(s) used in a statement.
const char* THD::thread_stack |
bool THD::time_zone_used |
struct THD_timer_info* THD::timer |
Holds active timer object.
struct THD_timer_info* THD::timer_cache |
After resetting(cancelling) timer, current timer object is cached with timer_cache timer to reuse.
uint THD::tmp_table |
|
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.
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.
bool THD::tx_commit_pending |
enum_tx_isolation THD::tx_isolation |
int THD::tx_priority |
bool THD::tx_read_only |
malloc_unordered_map<std::string, User_level_lock *> THD::ull_hash |
ulong THD::ulong_value |
ulonglong THD::ulonglong_value |
bool THD::unioned_events |
bool THD::unioned_events_trans |
uint32 THD::unmasked_server_id |
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.
struct timeval THD::user_time |
Prealloced_array<Binlog_user_var_event *, 2> THD::user_var_events |
MEM_ROOT* THD::user_var_events_alloc |
collation_unordered_map<std::string, unique_ptr_with_deleter<user_var_entry> > THD::user_vars {system_charset_info, key_memory_user_var_entry} |
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
.
System_variables THD::variables |
struct System_variables THD::variables |
|
private |
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.
const char* THD::where |
partition_info* THD::work_part_info |