MySQL 8.0.39
Source Code Documentation
sql_class.h File Reference
#include "my_config.h"
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
#include <atomic>
#include <bitset>
#include <memory>
#include <new>
#include <string>
#include "dur_prop.h"
#include "lex_string.h"
#include "m_ctype.h"
#include "map_helpers.h"
#include "my_alloc.h"
#include "my_base.h"
#include "my_command.h"
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_io.h"
#include "my_psi_config.h"
#include "my_sqlcommand.h"
#include "my_sys.h"
#include "my_table_map.h"
#include "my_thread_local.h"
#include "my_time_t.h"
#include "mysql/components/services/bits/my_thread_bits.h"
#include "mysql/components/services/bits/mysql_cond_bits.h"
#include "mysql/components/services/bits/mysql_mutex_bits.h"
#include "mysql/components/services/bits/psi_bits.h"
#include "mysql/components/services/bits/psi_idle_bits.h"
#include "mysql/components/services/bits/psi_stage_bits.h"
#include "mysql/components/services/bits/psi_statement_bits.h"
#include "mysql/components/services/bits/psi_thread_bits.h"
#include "mysql/components/services/bits/psi_transaction_bits.h"
#include "mysql/psi/mysql_mutex.h"
#include "mysql/psi/mysql_statement.h"
#include "mysql/psi/mysql_thread.h"
#include "mysql/thread_type.h"
#include "mysql_com.h"
#include "mysql_com_server.h"
#include "mysqld_error.h"
#include "pfs_thread_provider.h"
#include "prealloced_array.h"
#include "sql/auth/sql_security_ctx.h"
#include "sql/current_thd.h"
#include "sql/dd/string_type.h"
#include "sql/discrete_interval.h"
#include "sql/locked_tables_list.h"
#include "sql/mdl.h"
#include "sql/opt_costmodel.h"
#include "sql/opt_trace_context.h"
#include "sql/psi_memory_key.h"
#include "sql/query_options.h"
#include "sql/resourcegroups/resource_group_basic_types.h"
#include "sql/rpl_context.h"
#include "sql/rpl_gtid.h"
#include "sql/session_tracker.h"
#include "sql/sql_connect.h"
#include "sql/sql_const.h"
#include "sql/sql_digest_stream.h"
#include "sql/sql_error.h"
#include "sql/sql_list.h"
#include "sql/sql_plugin_ref.h"
#include "sql/sys_vars_resource_mgr.h"
#include "sql/system_variables.h"
#include "sql/transaction_info.h"
#include "sql/xa.h"
#include "sql_string.h"
#include "template_utils.h"
#include "thr_lock.h"
#include "violite.h"

Go to the source code of this file.

Classes

class  thd_scheduler
 To be used for pool-of-threads (implemented differently on various OSs) More...
 
class  Thd_mem_cnt
 
struct  rpl_event_coordinates
 the struct aggregates two parameters that identify an event uniquely in scope of communication of a particular master and slave couple. More...
 
class  Query_arena
 
class  Prepared_statement_map
 Container for all prepared statements created/used in a connection. More...
 
class  Item_change_record
 A registry for item tree transformations performed during query optimization. More...
 
class  Open_tables_state
 Class that holds information about tables which were opened and locked by the thread. More...
 
class  Open_tables_backup
 Storage for backup of Open_tables_state. More...
 
class  Sub_statement_state
 Used to save context when executing a function or trigger. More...
 
struct  Ha_data
 Storage engine specific thread local data. More...
 
class  Global_read_lock
 An instance of the global read lock in a connection. More...
 
class  Transactional_ddl_context
 This class keeps the context of transactional DDL statements. More...
 
class  THD
 For each client connection we create a separate thread with THD serving as a thread/connection descriptor. More...
 
class  THD::Query_plan
 Query plan for EXPLAINable commands, should be locked with LOCK_query_plan before using. More...
 
struct  THD::Transaction_state
 An utility struct for Attachable_trx. More...
 
class  THD::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  THD::Attachable_trx_rw
 A derived from THD::Attachable_trx class allows updates in the attachable transaction. More...
 

Namespaces

namespace  dd
 The version of the current data dictionary table definitions.
 
namespace  dd::cache
 

Macros

#define THD_STAGE_INFO(thd, stage)    (thd)->enter_stage(&stage, NULL, __func__, __FILE__, __LINE__)
 
#define THD_SENTRY_MAGIC   0xfeedd1ff
 
#define THD_SENTRY_GONE   0xdeadbeef
 
#define THD_CHECK_SENTRY(thd)   assert(thd->dbug_sentry == THD_SENTRY_MAGIC)
 
#define SUB_STMT_TRIGGER   1
 
#define SUB_STMT_FUNCTION   2
 
#define RETURN_NAME_AS_STRING(NAME)
 

Typedefs

typedef struct user_conn USER_CONN
 
typedef struct rpl_event_coordinates LOG_POS_COORD
 the struct aggregates two parameters that identify an event uniquely in scope of communication of a particular master and slave couple. More...
 
typedef I_List< Item_change_recordItem_change_list
 

Enumerations

enum class  TDM { ANY , ON , ZERO , NOT_AVAILABLE }
 
enum  enum_mem_cnt_mode { MEM_CNT_DEFAULT = 0U , MEM_CNT_UPDATE_GLOBAL_COUNTER = (1U << 0) , MEM_CNT_GENERATE_ERROR = (1U << 1) , MEM_CNT_GENERATE_LOG_ERROR = (1U << 2) }
 
enum class  Secondary_engine_optimization { PRIMARY_ONLY , PRIMARY_TENTATIVELY , SECONDARY }
 Enum that represents which phase of secondary engine optimization the current statement is in. More...
 

Functions

void thd_enter_cond (void *opaque_thd, 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)
 Set thread entering a condition. More...
 
void thd_exit_cond (void *opaque_thd, const PSI_stage_info *stage, const char *src_function, const char *src_file, int src_line)
 Set thread leaving a condition. More...
 
void thd_enter_stage (void *opaque_thd, const PSI_stage_info *new_stage, PSI_stage_info *old_stage, const char *src_function, const char *src_file, int src_line)
 
void thd_set_waiting_for_disk_space (void *opaque_thd, const bool waiting)
 
PSI_threadthd_get_psi (THD *thd)
 Get reference to Performance Schema object for THD object. More...
 
void thd_set_psi (THD *thd, PSI_thread *psi)
 Set reference to Performance Schema object for THD object. More...
 
unsigned int thd_get_current_thd_terminology_use_previous ()
 Return @session.terminology_use_previous for the current THD. More...
 
char const * show_system_thread (enum_thread_type thread)
 
void my_message_sql (uint error, const char *str, myf MyFlags)
 All global error messages are sent here where the first one is stored for the client. More...
 
bool secondary_engine_lock_tables_mode (const THD &cthd)
 Return lock_tables_mode for secondary engine. More...
 
void my_ok (THD *thd, ulonglong affected_rows=0, ulonglong id=0, const char *message=nullptr)
 A short cut for thd->get_stmt_da()->set_ok_status(). More...
 
void my_eof (THD *thd)
 A short cut for thd->get_stmt_da()->set_eof_status(). More...
 
bool add_item_to_list (THD *thd, Item *item)
 
bool is_engine_substitution_allowed (const THD *thd)
 Check if engine substitution is allowed in the current thread context. More...
 
bool is_xa_tran_detached_on_prepare (const THD *thd)
 Returns true if xa transactions are detached as part of executing XA PREPARE. More...
 

Variables

char empty_c_string [1]
 
constexpr size_t PREALLOC_NUM_HA = 15
 
thread_local TDM expected_from_debug_flag = TDM::ANY
 

Macro Definition Documentation

◆ RETURN_NAME_AS_STRING

#define RETURN_NAME_AS_STRING (   NAME)
Value:
case (NAME): \
return #NAME
#define NAME(f)
Definition: xcom_base.cc:4132

◆ SUB_STMT_FUNCTION

#define SUB_STMT_FUNCTION   2

◆ SUB_STMT_TRIGGER

#define SUB_STMT_TRIGGER   1

◆ THD_CHECK_SENTRY

#define THD_CHECK_SENTRY (   thd)    assert(thd->dbug_sentry == THD_SENTRY_MAGIC)

◆ THD_SENTRY_GONE

#define THD_SENTRY_GONE   0xdeadbeef

◆ THD_SENTRY_MAGIC

#define THD_SENTRY_MAGIC   0xfeedd1ff

◆ THD_STAGE_INFO

#define THD_STAGE_INFO (   thd,
  stage 
)     (thd)->enter_stage(&stage, NULL, __func__, __FILE__, __LINE__)

Typedef Documentation

◆ Item_change_list

◆ LOG_POS_COORD

the struct aggregates two parameters that identify an event uniquely in scope of communication of a particular master and slave couple.

I.e there can not be 2 events from the same staying connected master which have the same coordinates.

Note
Such identifier is not yet unique generally as the event originating master is resettable. Also the crashed master can be replaced with some other.

◆ USER_CONN

typedef struct user_conn USER_CONN

Enumeration Type Documentation

◆ enum_mem_cnt_mode

Enumerator
MEM_CNT_DEFAULT 

Memory counter object doesn't update global memory counter and doesn't throw OOM error.

MEM_CNT_UPDATE_GLOBAL_COUNTER 

if MEM_CNT_UPDATE_GLOBAL_COUNTER is set, memory counter object updates global memory counter.

MEM_CNT_GENERATE_ERROR 

if MEM_CNT_GENERATE_ERROR is set, memory counter object generates OOM error if any.

MEM_CNT_GENERATE_LOG_ERROR 

if MEM_CNT_GENERATE_LOG_ERROR is set, memory counter object generates OOM error to error log if any.

◆ Secondary_engine_optimization

enum class Secondary_engine_optimization
strong

Enum that represents which phase of secondary engine optimization the current statement is in.

Enumerator
PRIMARY_ONLY 

The current statement should only use tables from primary storage engines.

Use of secondary storage engines is disabled.

PRIMARY_TENTATIVELY 

The current statement should only use tables from the primary storage engine.

However, use of secondary storage engines is not disabled, so the optimizer may choose to trigger a repreparation against the secondary storage engine if it believes that use of a secondary storage engine is beneficial.

SECONDARY 

The current statement should use tables from a secondary storage engine if possible.

Otherwise, fall back to using tables from primary storage engine only.

◆ TDM

enum class TDM
strong
Enumerator
ANY 
ON 
ZERO 
NOT_AVAILABLE 

Function Documentation

◆ add_item_to_list()

bool add_item_to_list ( THD thd,
Item item 
)

◆ is_engine_substitution_allowed()

bool is_engine_substitution_allowed ( const THD thd)
inline

Check if engine substitution is allowed in the current thread context.

Parameters
thdthread context
Return values
trueif engine substitution is allowed
falseotherwise

◆ is_xa_tran_detached_on_prepare()

bool is_xa_tran_detached_on_prepare ( const THD thd)
inline

Returns true if xa transactions are detached as part of executing XA PREPARE.

◆ my_eof()

void my_eof ( THD thd)

A short cut for thd->get_stmt_da()->set_eof_status().

◆ my_message_sql()

void my_message_sql ( uint  error,
const char *  str,
myf  MyFlags 
)

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

◆ my_ok()

void my_ok ( THD thd,
ulonglong  affected_rows = 0,
ulonglong  id = 0,
const char *  message = nullptr 
)

A short cut for thd->get_stmt_da()->set_ok_status().

◆ secondary_engine_lock_tables_mode()

bool secondary_engine_lock_tables_mode ( const THD cthd)
inline

Return lock_tables_mode for secondary engine.

Parameters
cthdthread context
Return values
trueif lock_tables_mode is on
false,otherwise

◆ show_system_thread()

char const * show_system_thread ( enum_thread_type  thread)
inline

◆ thd_enter_cond()

void thd_enter_cond ( void *  opaque_thd,
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 
)

Set thread entering a condition.

This function should be called before putting a thread to wait for a condition. mutex should be held before calling this function. After being waken up, thd_exit_cond should be called.

Parameters
opaque_thdThe thread entering the condition, NULL means current thread
condThe condition the thread is going to wait for
mutexThe mutex associated with the condition, this must be held before call this function
stageThe new process message for the thread
old_stageThe old process message for the thread
src_functionThe caller source function name
src_fileThe caller source file name
src_lineThe caller source line number

◆ thd_enter_stage()

void thd_enter_stage ( void *  opaque_thd,
const PSI_stage_info new_stage,
PSI_stage_info old_stage,
const char *  src_function,
const char *  src_file,
int  src_line 
)

◆ thd_exit_cond()

void thd_exit_cond ( void *  opaque_thd,
const PSI_stage_info stage,
const char *  src_function,
const char *  src_file,
int  src_line 
)

Set thread leaving a condition.

This function should be called after a thread being waken up for a condition.

Parameters
opaque_thdThe thread entering the condition, NULL means current thread
stageThe process message, usually this should be the old process message before calling thd_enter_cond
src_functionThe caller source function name
src_fileThe caller source file name
src_lineThe caller source line number

◆ thd_get_current_thd_terminology_use_previous()

unsigned int thd_get_current_thd_terminology_use_previous ( )

Return @session.terminology_use_previous for the current THD.

Returns
the integer value of one of the enumeration values in terminology_use_previous::enum_compatibility_version.

◆ thd_get_psi()

PSI_thread * thd_get_psi ( THD thd)

Get reference to Performance Schema object for THD object.

Parameters
thdTHD object
Return values
Performanceschema object for thread on THD

◆ thd_set_psi()

void thd_set_psi ( THD thd,
PSI_thread psi 
)

Set reference to Performance Schema object for THD object.

Parameters
thdTHD object
psiPerformance schema object for thread

◆ thd_set_waiting_for_disk_space()

void thd_set_waiting_for_disk_space ( void *  opaque_thd,
const bool  waiting 
)

Variable Documentation

◆ empty_c_string

char empty_c_string[1]
extern

◆ expected_from_debug_flag

thread_local TDM expected_from_debug_flag = TDM::ANY
inline

◆ PREALLOC_NUM_HA

constexpr size_t PREALLOC_NUM_HA = 15
constexpr