24#ifndef SQL_CLASS_INCLUDED
25#define SQL_CLASS_INCLUDED
51#include <unordered_map>
85#include "mysqld_error.h"
148class Dictionary_client;
151class DD_kill_immunizer;
171 const char *src_function,
const char *src_file,
174 const char *src_function,
const char *src_file,
180 const char *src_function,
const char *src_file,
186#define THD_STAGE_INFO(thd, stage) \
187 (thd)->enter_stage(&stage, NULL, __func__, __FILE__, __LINE__)
343#define THD_SENTRY_MAGIC 0xfeedd1ff
344#define THD_SENTRY_GONE 0xdeadbeef
346#define THD_CHECK_SENTRY(thd) assert(thd->dbug_sentry == THD_SENTRY_MAGIC)
428 template <
typename T>
430 void *m =
alloc(
sizeof(T));
431 return m ==
nullptr ?
nullptr :
new (m) T;
433 template <
typename T>
740#define SUB_STMT_TRIGGER 1
741#define SUB_STMT_FUNCTION 2
760#define RETURN_NAME_AS_STRING(NAME) \
780 sprintf(
buf,
"<UNKNOWN SYSTEM THREAD: %d>", thread);
783#undef RETURN_NAME_AS_STRING
889 assert(
m_thd !=
nullptr);
921 std::pair<Event_tracking_class, Event_tracking_information *>;
1070 std::unique_ptr<Secondary_engine_statement_context>
1104 std::unique_ptr<Secondary_engine_statement_context> context);
1385 return pointer_cast<const Protocol_classic *>(
m_protocol);
1508 const char *calling_func,
const char *calling_file,
1728 bool binlog_rows_query);
1731 const unsigned char *extra_row_info);
1733 const uchar *old_data,
1734 const unsigned char *extra_row_info);
1737 const uchar *extra_row_info);
1743 template <
class RowsEventT>
1746 const unsigned char *extra_row_info,
uint32 source_part_id = INT_MAX);
2470#if defined(ENABLED_PROFILING)
2485#ifdef HAVE_PSI_STATEMENT_INTERFACE
2492#ifdef HAVE_PSI_TRANSACTION_INTERFACE
2499#ifdef HAVE_PSI_IDLE_INTERFACE
2650 assert(((
file ==
nullptr) && (pos == 0)) ||
2651 ((
file !=
nullptr) && (pos != 0)));
2667 (
"m_trans_log_file: %s, m_trans_fixed_log_file: %s, "
2668 "m_trans_end_pos: %llu",
2678 (
"file: %s, pos: %llu", file_var ? *file_var :
"<none>",
2679 pos_var ? *pos_var : 0));
2688 (
"file: %s, pos: %llu", file_var ? *file_var :
"<none>",
2689 pos_var ? *pos_var : 0));
2873#if defined(ENABLED_DEBUG_SYNC)
2875 struct st_debug_sync_control *debug_sync_control;
2889 explicit THD(
bool enable_plugins =
true);
2940 enum_thd_life_cycle_stages::ACTIVE};
3026 void disconnect(
bool server_shutdown =
false);
3039 size_t query_len,
bool is_trans,
bool direct,
3040 bool suppress_use,
int errcode);
3046 const char *src_function,
const char *src_file,
3047 int src_line)
override {
3057 enter_stage(stage, old_stage, src_function, src_file, src_line);
3062 const char *src_file,
int src_line)
override {
3074 enter_stage(stage,
nullptr, src_function, src_file, src_line);
3110 bool needs_thr_lock_abort)
override;
3113 bool *victimized)
override;
3242 const char *from,
size_t from_length,
3264 bool is_connected(
bool use_cached_connection_alive =
false) final;
3335 bool copy_conditions =
true) {
3353 template <
typename ProtocolClass>
3374 DBUG_PRINT(
"info", (
"change_item_tree place %p old_value %p new_value %p",
3375 place, *place, new_value));
3405 uint add_state_flags);
3517 return variables.gtid_next_list.is_non_null
3851 auto xid_state = trx->xid_state();
3866 auto xid_state = trx->xid_state();
3870#ifdef HAVE_GTID_NEXT_LIST
3895#ifdef HAVE_GTID_NEXT_LIST
3896 owned_gtid_set.
clear();
3979#ifdef HAVE_PSI_THREAD_INTERFACE
3999 return copy_db_to(
const_cast<char const **
>(p_db), p_db_length);
4119 uint code,
const char *message_text);
4189 size_t query_length_arg [[maybe_unused]]) {
4192 static_cast<uint
>(query_length_arg));
4193#ifdef HAVE_PSI_THREAD_INTERFACE
4196 (query_arg,
static_cast<uint
>(query_length_arg));
4221 void set_query(
const char *query_arg,
size_t query_length_arg) {
4222 const LEX_CSTRING tmp = {query_arg, query_length_arg};
4377 bool some_non_transactional_table,
4378 bool non_transactional_tables_are_tmp);
4462 MY_ATTRIBUTE((format(printf, 2, 3)));
4469 MY_ATTRIBUTE((format(printf, 3, 4)));
4473 MY_ATTRIBUTE((format(printf, 3, 0)));
4474 void vsyntax_error_at(const
char *pos_in_lexer_raw_buffer, const
char *format,
4475 va_list args) MY_ATTRIBUTE((format(printf, 3, 0)));
4806 unsigned long subevent,
bool check_audited);
4845 const char *message =
nullptr);
4908 return thd->
variables.xa_detach_on_prepare;
app_data_ptr new_data(u_int n, char *val, cons_type consensus)
uint32_t Access_bitmask
Definition: auth_acls.h:34
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
int64 query_id_t
Definition: binlog.h:72
API for getting cost estimates for server operations that are not directly related to a table object.
Definition: opt_costmodel.h:54
Stores status of the currently executed statement.
Definition: sql_error.h:269
bool is_error() const
Definition: sql_error.h:366
void reset_diagnostics_area()
Clear this Diagnostics Area.
Definition: sql_error.cc:361
Diagnostics_area * pop_diagnostics_area()
Pop "this" off the Diagnostics Area stack.
Definition: sql_error.cc:643
const Diagnostics_area * stacked_da() const
Returns the Diagnostics Area below the current diagnostics area on the stack.
Definition: sql_error.h:592
void push_diagnostics_area(THD *thd, Diagnostics_area *da, bool copy_conditions)
Push the given Diagnostics Area on top of the stack.
Definition: sql_error.cc:632
List of Discrete_interval objects.
Definition: discrete_interval.h:87
bool append(Discrete_interval *new_interval)
Definition: discrete_interval.h:117
void clear()
Definition: discrete_interval.h:144
Definition: reference_caching_setup.h:109
void refresh_all()
Definition: reference_caching_setup.cc:247
An instance of the global read lock in a connection.
Definition: sql_class.h:833
bool can_acquire_protection() const
Check if this connection can acquire protection against GRL and emit error if otherwise.
Definition: sql_class.h:853
MDL_ticket * m_mdl_blocks_commits_lock
Also in order to acquire the global read lock, the connection must acquire a shared metadata lock in ...
Definition: sql_class.h:877
MDL_ticket * m_mdl_global_shared_lock
In order to acquire the global read lock, the connection must acquire shared metadata lock in GLOBAL ...
Definition: sql_class.h:871
enum_grl_state m_state
Definition: sql_class.h:865
bool is_acquired() const
Definition: sql_class.h:861
Global_read_lock()
Definition: sql_class.h:841
enum_grl_state
Definition: sql_class.h:835
@ GRL_ACQUIRED_AND_BLOCKS_COMMIT
Definition: sql_class.h:838
@ GRL_ACQUIRED
Definition: sql_class.h:837
@ GRL_NONE
Definition: sql_class.h:836
Represents a set of GTIDs.
Definition: rpl_gtid.h:1556
void clear()
Removes all gtids from this Gtid_set.
Definition: rpl_gtid_set.cc:265
Either statement transaction or normal transaction - related thread-specific storage engine data.
Definition: transaction_info.h:414
This class represents the interface for internal error handlers.
Definition: error_handler.h:47
A registry for item tree transformations performed during query optimization.
Definition: sql_class.h:535
bool m_cancel
Definition: sql_class.h:546
Item * old_value
Definition: sql_class.h:544
Item_change_record(Item **place, Item *new_value)
Definition: sql_class.h:541
Item ** place
Definition: sql_class.h:543
Item * new_value
Definition: sql_class.h:545
Item_change_record()=default
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:930
Definition: sql_list.h:467
Tables that were locked with LOCK TABLES statement.
Definition: locked_tables_list.h:89
An interface to separate the MDL module from the THD, and the rest of the server code.
Definition: mdl.h:85
Context of the owner of metadata locks.
Definition: mdl.h:1412
void set_explicit_duration_for_all_locks()
Set explicit duration for all locks in the context.
Definition: mdl.cc:4632
Savepoint for MDL context.
Definition: mdl.h:1317
A granted metadata lock.
Definition: mdl.h:985
Table modification plan for JOIN-less statements (update/delete)
Definition: opt_explain.h:82
Storage for backup of Open_tables_state.
Definition: sql_class.h:693
MDL_savepoint mdl_system_tables_svp
When we backup the open tables state to open a system table or tables, we want to save state of metad...
Definition: sql_class.h:702
Class that holds information about tables which were opened and locked by the thread.
Definition: sql_class.h:557
MYSQL_LOCK * lock
Definition: sql_class.h:625
TABLE * open_tables
List of regular tables in use by this thread.
Definition: sql_class.h:604
MYSQL_LOCK * extra_lock
Definition: sql_class.h:632
Open_tables_state()
This constructor initializes Open_tables_state instance which can only be used as backup storage.
Definition: sql_class.h:679
uint state_flags
Definition: sql_class.h:672
void reset_open_tables_state()
Definition: sql_class.cc:619
Reprepare_observer * pop_reprepare_observer()
Definition: sql_class.h:591
void push_reprepare_observer(Reprepare_observer *o)
Definition: sql_class.h:587
enum_flags
Definition: sql_class.h:664
@ BACKUPS_AVAIL
Definition: sql_class.h:665
@ SYSTEM_TABLES
Definition: sql_class.h:666
enum enum_locked_tables_mode locked_tables_mode
Definition: sql_class.h:662
Reprepare_observer * get_reprepare_observer() const
Definition: sql_class.h:582
TABLE * temporary_tables
List of temporary tables used by this thread.
Definition: sql_class.h:610
void reset_reprepare_observers()
Definition: sql_class.h:597
void set_open_tables_state(Open_tables_state *state)
Definition: sql_class.cc:604
Prealloced_array< Reprepare_observer *, 4 > m_reprepare_observers
A stack of Reprepare_observer-instances.
Definition: sql_class.h:579
A per-session context which is always available at any point of execution, because in practice it's a...
Definition: opt_trace_context.h:94
Profiling state for a single THD; contains multiple QUERY_PROFILE objects.
Definition: sql_profile.h:226
Internal state of the parser.
Definition: sql_lexer_parser_state.h:44
Plugin array helper class.
Definition: sql_plugin_ref.h:110
A typesafe replacement for DYNAMIC_ARRAY.
Definition: prealloced_array.h:71
Container for all prepared statements created/used in a connection.
Definition: sql_class.h:483
Prepared_statement_map()
Definition: sql_class.cc:2077
void claim_memory_ownership(bool claim)
Definition: sql_class.cc:2139
Prepared_statement * find_by_name(const LEX_CSTRING &name)
Find prepared statement by name.
Definition: sql_class.cc:2114
int insert(Prepared_statement *statement)
Insert a new statement to the thread-local prepared statement map.
Definition: sql_class.cc:2083
Prepared_statement * m_last_found_statement
Definition: sql_class.h:525
~Prepared_statement_map()
Definition: sql_class.cc:2163
void reset()
Definition: sql_class.cc:2145
void erase(Prepared_statement *statement)
Erase all prepared statements (calls Prepared_statement destructor).
Definition: sql_class.cc:2128
collation_unordered_map< std::string, Prepared_statement * > names_hash
Definition: sql_class.h:524
malloc_unordered_map< ulong, std::unique_ptr< Prepared_statement > > st_hash
Definition: sql_class.h:523
Prepared_statement * find(ulong id)
Find prepared statement by ID.
Definition: sql_class.cc:2119
Prepared_statement: a statement that can contain placeholders.
Definition: sql_prepare.h:150
Definition: protocol_classic.h:242
Definition: protocol_classic.h:54
Class used for the old (MySQL 4.0 protocol).
Definition: protocol_classic.h:220
Definition: protocol.h:33
Definition: sql_class.h:348
enum_state get_state() const
Definition: sql_class.h:411
bool is_stmt_prepare_or_first_stmt_execute() const
Definition: sql_class.h:416
T * memdup_typed(const T *mem)
Definition: sql_class.h:434
enum_state
Definition: sql_class.h:367
@ STMT_INITIALIZED
Definition: sql_class.h:368
@ STMT_ERROR
Definition: sql_class.h:373
@ STMT_REGULAR_EXECUTION
Definition: sql_class.h:371
@ STMT_PREPARED
Definition: sql_class.h:370
@ STMT_INITIALIZED_FOR_SP
Definition: sql_class.h:369
@ STMT_EXECUTED
Definition: sql_class.h:372
bool is_repreparing
To check whether a reprepare operation is active.
Definition: sql_class.h:359
bool is_stmt_prepare() const
Definition: sql_class.h:412
LEX_CSTRING strmake(LEX_CSTRING str)
Definition: sql_class.h:441
void reset_item_list()
Definition: sql_class.h:406
char * mem_strdup(const char *str)
Definition: sql_class.h:437
void free_items()
Definition: sql_class.cc:2041
Item * m_item_list
Definition: sql_class.h:354
void * alloc(size_t size)
Definition: sql_class.h:422
Query_arena(MEM_ROOT *mem_root_arg, enum enum_state state_arg)
Definition: sql_class.h:393
bool is_regular() const
Definition: sql_class.h:420
void set_query_arena(const Query_arena &set)
Copies memory-managing members from set.
Definition: sql_class.cc:2052
char * strmake(const char *str, size_t size) const
Definition: sql_class.h:438
enum_state state
Definition: sql_class.h:390
void set_item_list(Item *item)
Definition: sql_class.h:407