MySQL  8.0.15
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 <memory>
#include "m_ctype.h"
#include "my_alloc.h"
#include "my_compiler.h"
#include "mysql/components/services/mysql_cond_bits.h"
#include "mysql/components/services/mysql_mutex_bits.h"
#include "mysql/components/services/psi_idle_bits.h"
#include "mysql/components/services/psi_stage_bits.h"
#include "mysql/components/services/psi_statement_bits.h"
#include "mysql/components/services/psi_thread_bits.h"
#include "mysql/components/services/psi_transaction_bits.h"
#include "mysql/psi/mysql_thread.h"
#include "pfs_thread_provider.h"
#include "sql/psi_memory_key.h"
#include "sql/resourcegroups/resource_group_basic_types.h"
#include "sql/xa.h"
#include <sys/types.h>
#include <time.h>
#include <atomic>
#include <new>
#include <string>
#include "dur_prop.h"
#include "lex_string.h"
#include "map_helpers.h"
#include "my_base.h"
#include "my_command.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 "mysql/psi/mysql_mutex.h"
#include "mysql/psi/mysql_statement.h"
#include "mysql/psi/psi_base.h"
#include "mysql/thread_type.h"
#include "mysql_com.h"
#include "mysql_com_server.h"
#include "mysqld_error.h"
#include "prealloced_array.h"
#include "sql/auth/sql_security_ctx.h"
#include "sql/current_thd.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/protocol.h"
#include "sql/protocol_classic.h"
#include "sql/query_options.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_string.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...
 
struct  rpl_event_coordinates
 the struct aggregates two paramenters 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  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...
 
class  Internal_error_handler_holder< Error_handler, Error_handler_arg >
 A simple holder for Internal_error_handler. More...
 
class  Prepared_stmt_arena_holder
 A simple holder for the Prepared Statement Query_arena instance in THD. More...
 
class  Column_privilege_tracker
 RAII class for column privilege checking. More...
 

Namespaces

 dd
 The version of the current data dictionary table definitions.
 
 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)   DBUG_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 paramenters 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
 

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...
 
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...
 
static void my_micro_time_to_timeval (ulonglong micro_time, struct timeval *tm)
 Convert microseconds since epoch to timeval. More...
 
void my_ok (THD *thd, ulonglong affected_rows=0, ulonglong id=0, const char *message=NULL)
 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)
 
void add_order_to_list (THD *thd, ORDER *order)
 
void reattach_engine_ha_data_to_thd (THD *thd, const struct handlerton *hton)
 The function re-attaches the engine ha_data (which was previously detached by detach_ha_data_from_thd) to THD. More...
 
static bool is_engine_substitution_allowed (THD *thd)
 Check if engine substitution is allowed in the current thread context. More...
 

Variables

char empty_c_string [1]
 
LEX_STRING EMPTY_STR
 
LEX_STRING NULL_STR
 
LEX_CSTRING EMPTY_CSTR
 
LEX_CSTRING NULL_CSTR
 
constexpr size_t PREALLOC_NUM_HA = 15
 

Macro Definition Documentation

◆ RETURN_NAME_AS_STRING

#define RETURN_NAME_AS_STRING (   NAME)
Value:
case (NAME): \
return #NAME

◆ SUB_STMT_FUNCTION

#define SUB_STMT_FUNCTION   2

◆ SUB_STMT_TRIGGER

#define SUB_STMT_TRIGGER   1

◆ THD_CHECK_SENTRY

#define THD_CHECK_SENTRY (   thd)    DBUG_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 paramenters 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 resetable. Also the crashed master can be replaced with some other.

◆ USER_CONN

typedef struct user_conn USER_CONN

Function Documentation

◆ add_item_to_list()

bool add_item_to_list ( THD thd,
Item item 
)

◆ add_order_to_list()

void add_order_to_list ( THD thd,
ORDER order 
)

◆ is_engine_substitution_allowed()

static bool is_engine_substitution_allowed ( THD thd)
inlinestatic

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

Parameters
thdthread context
Returns
Return values
trueif engine substitution is allowed
falseotherwise

◆ my_eof()

void my_eof ( THD thd)
inline

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_micro_time_to_timeval()

static void my_micro_time_to_timeval ( ulonglong  micro_time,
struct timeval *  tm 
)
inlinestatic

Convert microseconds since epoch to timeval.

Parameters
micro_timeMicroseconds.
[out]tmA timeval variable to write to.

◆ my_ok()

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

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

◆ reattach_engine_ha_data_to_thd()

void reattach_engine_ha_data_to_thd ( THD thd,
const struct handlerton hton 
)

The function re-attaches the engine ha_data (which was previously detached by detach_ha_data_from_thd) to THD.

This is typically done to replication applier executing one of XA-PREPARE, XA-COMMIT ONE PHASE or rollback.

Parameters
thdthread context
htonpointer to handlerton

◆ 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_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]

◆ EMPTY_CSTR

LEX_CSTRING EMPTY_CSTR

◆ EMPTY_STR

LEX_STRING EMPTY_STR

◆ NULL_CSTR

LEX_CSTRING NULL_CSTR

◆ NULL_STR

LEX_STRING NULL_STR

◆ PREALLOC_NUM_HA

constexpr size_t PREALLOC_NUM_HA = 15