MySQL 8.0.40
Source Code Documentation
|
#include "sql/sql_thd_internal_api.h"
#include <algorithm>
#include "my_config.h"
#include <fcntl.h>
#include <string.h>
#include "m_string.h"
#include "mysql/components/services/bits/psi_stage_bits.h"
#include "pfs_thread_provider.h"
#include <unistd.h>
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_io.h"
#include "my_macros.h"
#include "my_psi_config.h"
#include "my_sys.h"
#include "mysql/psi/mysql_file.h"
#include "mysql/psi/mysql_mutex.h"
#include "mysql/psi/mysql_socket.h"
#include "mysql/thread_type.h"
#include "sql/binlog.h"
#include "sql/current_thd.h"
#include "sql/mysqld.h"
#include "sql/mysqld_thd_manager.h"
#include "sql/protocol_classic.h"
#include "sql/query_options.h"
#include "sql/rpl_filter.h"
#include "sql/sql_class.h"
#include "sql/sql_lex.h"
#include "sql/sql_parse.h"
#include "sql/system_variables.h"
#include "sql/transaction_info.h"
#include "violite.h"
Functions | |
THD * | create_internal_thd () |
void | destroy_internal_thd (THD *thd) |
void | thd_init (THD *thd, char *stack_start) |
Set up various THD data for a new connection. More... | |
void | thd_init (THD *thd, char *stack_start, bool bound, PSI_thread_key psi_key, unsigned int psi_seqnum) |
Set up various THD data for a new connection. More... | |
THD * | create_thd (bool enable_plugins, bool background_thread, bool bound, PSI_thread_key psi_key, unsigned int psi_seqnum) |
Create a THD and do proper initialization of it. More... | |
void | destroy_thd (THD *thd, bool clear_pfs_events) |
Cleanup the THD object, remove it from the global list of THDs and delete it. More... | |
void | destroy_thd (THD *thd) |
Cleanup the THD object, remove it from the global list of THDs and delete it. More... | |
void | thd_set_thread_stack (THD *thd, const char *stack_start) |
Set thread stack in THD object. More... | |
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) |
void | thd_increment_bytes_sent (size_t length) |
void | thd_increment_bytes_received (size_t length) |
partition_info * | thd_get_work_part_info (THD *thd) |
Returns the partition_info working copy. More... | |
enum_tx_isolation | thd_get_trx_isolation (const THD *thd) |
const CHARSET_INFO * | thd_charset (THD *thd) |
LEX_CSTRING | thd_query_unsafe (THD *thd) |
Get the current query string for the thread. More... | |
size_t | thd_query_safe (THD *thd, char *buf, size_t buflen) |
Get the current query string for the thread. More... | |
int | thd_slave_thread (const THD *thd) |
Check if a user thread is a replication slave thread. More... | |
int | thd_non_transactional_update (const THD *thd) |
Check if a user thread is running a non-transactional update. More... | |
int | thd_binlog_format (const THD *thd) |
Get the user thread's binary logging format. More... | |
bool | thd_binlog_filter_ok (const THD *thd) |
Check if binary logging is filtered for thread's current db. More... | |
bool | thd_sqlcom_can_generate_row_events (const THD *thd) |
Check if the query may generate row changes which may end up in the binary. More... | |
enum durability_properties | thd_get_durability_property (const THD *thd) |
Gets information on the durability property requested by a thread. More... | |
void | thd_get_autoinc (const THD *thd, ulong *off, ulong *inc) |
Get the auto_increment_offset auto_increment_increment. More... | |
size_t | thd_get_tmp_table_size (const THD *thd) |
Get the tmp_table_size threshold. More... | |
bool | thd_is_strict_mode (const THD *thd) |
Is strict sql_mode set. More... | |
bool | thd_is_error (const THD *thd) |
Is an error set in the DA. More... | |
bool | is_mysql_datadir_path (const char *path) |
Test a file path whether it is same as mysql data directory path. More... | |
int | mysql_tmpfile_path (const char *path, const char *prefix) |
Create a temporary file. More... | |
bool | thd_is_bootstrap_thread (THD *thd) |
Check if the server is in the process of being initialized. More... | |
bool | thd_is_dd_update_stmt (const THD *thd) |
Is statement updating the data dictionary tables. More... | |
my_thread_id | thd_thread_id (const THD *thd) |
THD * create_internal_thd | ( | ) |
THD * create_thd | ( | bool | enable_plugins, |
bool | background_thread, | ||
bool | bound, | ||
PSI_thread_key | psi_key, | ||
unsigned int | psi_seqnum | ||
) |
Create a THD and do proper initialization of it.
enable_plugins | Should dynamic plugin support be enabled? |
background_thread | Is this a background thread? |
bound | True if bound to a physical thread. |
psi_key | Instrumentation key for the thread. |
psi_seqnum | Instrumentation sequence number for the thread. |
void destroy_internal_thd | ( | THD * | thd | ) |
void destroy_thd | ( | THD * | thd | ) |
Cleanup the THD object, remove it from the global list of THDs and delete it.
thd | Pointer to THD object. |
void destroy_thd | ( | THD * | thd, |
bool | clear_pfs_instr | ||
) |
Cleanup the THD object, remove it from the global list of THDs and delete it.
thd | Pointer to THD object. |
clear_pfs_instr | If true, then clear thread PFS instrumentations. |
bool is_mysql_datadir_path | ( | const char * | path | ) |
Test a file path whether it is same as mysql data directory path.
path | null terminated character string |
true | The path is different from mysql data directory. |
false | The path is same as mysql data directory. |
int mysql_tmpfile_path | ( | const char * | path, |
const char * | prefix | ||
) |
Create a temporary file.
The temporary file is created in a location specified by the parameter path. if path is null, then it will be created on the location given by the mysql server configuration (–tmpdir option). The caller does not need to delete the file, it will be deleted automatically.
path | location for creating temporary file |
prefix | prefix for temporary file name |
-1 | error |
>=0 | a file handle that can be passed to dup or my_close |
bool thd_binlog_filter_ok | ( | const THD * | thd | ) |
Check if binary logging is filtered for thread's current db.
thd | Thread handle |
1 | the query is not filtered, 0 otherwise. |
int thd_binlog_format | ( | const THD * | thd | ) |
Get the user thread's binary logging format.
thd | user thread |
const CHARSET_INFO * thd_charset | ( | THD * | thd | ) |
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.
opaque_thd | The thread entering the condition, NULL means current thread |
cond | The condition the thread is going to wait for |
mutex | The mutex associated with the condition, this must be held before call this function |
stage | The new process message for the thread |
old_stage | The old process message for the thread |
src_function | The caller source function name |
src_file | The caller source file name |
src_line | The caller source line number |
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_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.
opaque_thd | The thread entering the condition, NULL means current thread |
stage | The process message, usually this should be the old process message before calling thd_enter_cond |
src_function | The caller source function name |
src_file | The caller source file name |
src_line | The caller source line number |
void thd_get_autoinc | ( | const THD * | thd, |
ulong * | off, | ||
ulong * | inc | ||
) |
Get the auto_increment_offset auto_increment_increment.
thd | Thread object |
off | auto_increment_offset |
inc | auto_increment_increment |
enum durability_properties thd_get_durability_property | ( | const THD * | thd | ) |
Gets information on the durability property requested by a thread.
thd | Thread handle |
size_t thd_get_tmp_table_size | ( | const THD * | thd | ) |
Get the tmp_table_size threshold.
thd | Thread object |
enum_tx_isolation thd_get_trx_isolation | ( | const THD * | thd | ) |
partition_info * thd_get_work_part_info | ( | THD * | thd | ) |
Returns the partition_info working copy.
Used to see if a table should be created with partitioning.
thd | thread context |
void thd_increment_bytes_received | ( | size_t | length | ) |
void thd_increment_bytes_sent | ( | size_t | length | ) |
void thd_init | ( | THD * | thd, |
char * | stack_start | ||
) |
Set up various THD data for a new connection.
thd | THD object |
stack_start | Start of stack for connection |
void thd_init | ( | THD * | thd, |
char * | stack_start, | ||
bool | bound, | ||
PSI_thread_key | psi_key, | ||
unsigned int | psi_seqnum | ||
) |
Set up various THD data for a new connection.
thd | THD object |
stack_start | Start of stack for connection |
bound | True if bound to a physical thread. |
psi_key | Instrumentation key for the thread. |
psi_seqnum | Instrumentation sequence number for the thread. |
bool thd_is_bootstrap_thread | ( | THD * | thd | ) |
Check if the server is in the process of being initialized.
Check the thread type of the THD. If this is a thread type being used for initializing the DD or the server, return true.
thd | Needed since this is an opaque type in the SE. |
true | The thread is a bootstrap thread. |
false | The thread is not a bootstrap thread. |
bool thd_is_dd_update_stmt | ( | const THD * | thd | ) |
Is statement updating the data dictionary tables.
The thread switches to the data dictionary tables update context using the dd::Update_dictionary_tables_ctx while updating dictionary tables. If thread is in this context then the method returns true otherwise false. This method is used by the InnoDB while updating the tables to mark transaction as DDL if this method returns true.
thd | Thread handle. |
true | Updates data dictionary tables. |
false | Otherwise. |
bool thd_is_error | ( | const THD * | thd | ) |
Is an error set in the DA.
Needed by InnoDB to catch behavior modified by an error handler.
thd | Thread object |
true | An error has been raised. |
false | No error has been raised. |
bool thd_is_strict_mode | ( | const THD * | thd | ) |
Is strict sql_mode set.
Needed by InnoDB.
thd | Thread object |
true | sql_mode has strict mode (all or trans). |
false | sql_mode has not strict mode (all or trans). |
int thd_non_transactional_update | ( | const THD * | thd | ) |
Check if a user thread is running a non-transactional update.
thd | user thread |
0 | the user thread is not running a non-transactional update |
1 | the user thread is running a non-transactional update |
size_t thd_query_safe | ( | THD * | thd, |
char * | buf, | ||
size_t | buflen | ||
) |
Get the current query string for the thread.
thd | The MySQL internal thread pointer |
buf | Buffer where the query string will be copied |
buflen | Length of the buffer |
LEX_CSTRING thd_query_unsafe | ( | THD * | thd | ) |
Get the current query string for the thread.
thd | The MySQL internal thread pointer |
void thd_set_thread_stack | ( | THD * | thd, |
const char * | stack_start | ||
) |
Set thread stack in THD object.
thd | Thread object |
stack_start | Start of stack to set in THD object |
void thd_set_waiting_for_disk_space | ( | void * | opaque_thd, |
const bool | waiting | ||
) |
int thd_slave_thread | ( | const THD * | thd | ) |
Check if a user thread is a replication slave thread.
thd | user thread |
0 | the user thread is not a replication slave thread |
1 | the user thread is a replication slave thread |
bool thd_sqlcom_can_generate_row_events | ( | const THD * | thd | ) |
Check if the query may generate row changes which may end up in the binary.
thd | Thread handle |
1 | the query may generate row changes, 0 otherwise. |
my_thread_id thd_thread_id | ( | const THD * | thd | ) |