MySQL 9.0.0
Source Code Documentation
sql_thd_internal_api.h File Reference
#include <stddef.h>
#include <sys/types.h>
#include "dur_prop.h"
#include "lex_string.h"
#include "mysql/components/services/bits/psi_thread_bits.h"
#include "mysql/strings/m_ctype.h"
#include "sql/handler.h"

Go to the source code of this file.

Functions

THDcreate_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...
 
THDcreate_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_instr)
 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...
 
partition_infothd_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_INFOthd_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...
 
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)
 

Function Documentation

◆ create_internal_thd()

THD * create_internal_thd ( )

◆ create_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.

Parameters
enable_pluginsShould dynamic plugin support be enabled?
background_threadIs this a background thread?
boundTrue if bound to a physical thread.
psi_keyInstrumentation key for the thread.
psi_seqnumInstrumentation sequence number for the thread.
Note
Dynamic plugin support is only possible for THDs that are created after the server has initialized properly.
THDs for background threads are currently not added to the global THD list. So they will e.g. not be visible in SHOW PROCESSLIST and the server will not wait for them to terminate during shutdown.

◆ destroy_internal_thd()

void destroy_internal_thd ( THD thd)

◆ destroy_thd() [1/2]

void destroy_thd ( THD thd)

Cleanup the THD object, remove it from the global list of THDs and delete it.

Parameters
thdPointer to THD object.

◆ destroy_thd() [2/2]

void destroy_thd ( THD thd,
bool  clear_pfs_instr 
)

Cleanup the THD object, remove it from the global list of THDs and delete it.

Parameters
thdPointer to THD object.
clear_pfs_instrIf true, then clear thread PFS instrumentations.

◆ is_mysql_datadir_path()

bool is_mysql_datadir_path ( const char *  path)

Test a file path whether it is same as mysql data directory path.

Parameters
pathnull terminated character string
Return values
trueThe path is different from mysql data directory.
falseThe path is same as mysql data directory.

◆ mysql_tmpfile_path()

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.

Parameters
pathlocation for creating temporary file
prefixprefix for temporary file name
Return values
-1error
>=0a file handle that can be passed to dup or my_close

◆ thd_binlog_filter_ok()

bool thd_binlog_filter_ok ( const THD thd)

Check if binary logging is filtered for thread's current db.

Parameters
thdThread handle
Return values
1the query is not filtered, 0 otherwise.

◆ thd_binlog_format()

int thd_binlog_format ( const THD thd)

Get the user thread's binary logging format.

Parameters
thduser thread
Returns
Value to be used as index into the binlog_format_names array

◆ thd_charset()

const CHARSET_INFO * thd_charset ( THD thd)

◆ thd_get_autoinc()

void thd_get_autoinc ( const THD thd,
ulong *  off,
ulong *  inc 
)

Get the auto_increment_offset auto_increment_increment.

Parameters
thdThread object
offauto_increment_offset
incauto_increment_increment

◆ thd_get_durability_property()

durability_properties thd_get_durability_property ( const THD thd)

Gets information on the durability property requested by a thread.

Parameters
thdThread handle
Returns
a durability property.

◆ thd_get_tmp_table_size()

size_t thd_get_tmp_table_size ( const THD thd)

Get the tmp_table_size threshold.

Parameters
thdThread object
Returns
Value of currently set tmp_table_size threshold.

◆ thd_get_trx_isolation()

enum_tx_isolation thd_get_trx_isolation ( const THD thd)

◆ thd_get_work_part_info()

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.

Parameters
thdthread context
Returns
Pointer to the working copy of partition_info or NULL.

◆ thd_init() [1/2]

void thd_init ( THD thd,
char *  stack_start 
)

Set up various THD data for a new connection.

Note
PFS instrumentation is not set by this function.
Parameters
thdTHD object
stack_startStart of stack for connection

◆ thd_init() [2/2]

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.

Parameters
thdTHD object
stack_startStart of stack for connection
boundTrue if bound to a physical thread.
psi_keyInstrumentation key for the thread.
psi_seqnumInstrumentation sequence number for the thread.

◆ thd_is_bootstrap_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.

Parameters
thdNeeded since this is an opaque type in the SE.
Return values
trueThe thread is a bootstrap thread.
falseThe thread is not a bootstrap thread.

◆ thd_is_dd_update_stmt()

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.

Parameters
thdThread handle.
Return values
trueUpdates data dictionary tables.
falseOtherwise.

◆ thd_is_error()

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.

Parameters
thdThread object
Returns
True if THD::is_error() returns true.
Return values
trueAn error has been raised.
falseNo error has been raised.

◆ thd_is_strict_mode()

bool thd_is_strict_mode ( const THD thd)

Is strict sql_mode set.

Needed by InnoDB.

Parameters
thdThread object
Returns
True if sql_mode has strict mode (all or trans).
Return values
truesql_mode has strict mode (all or trans).
falsesql_mode has not strict mode (all or trans).

◆ thd_non_transactional_update()

int thd_non_transactional_update ( const THD thd)

Check if a user thread is running a non-transactional update.

Parameters
thduser thread
Return values
0the user thread is not running a non-transactional update
1the user thread is running a non-transactional update

◆ thd_query_safe()

size_t thd_query_safe ( THD thd,
char *  buf,
size_t  buflen 
)

Get the current query string for the thread.

Parameters
thdThe MySQL internal thread pointer
bufBuffer where the query string will be copied
buflenLength of the buffer
Returns
Length of the query
Note
This function is thread safe as the query string is accessed under mutex protection and the string is copied into the provided buffer.
See also
thd_query_unsafe().

◆ thd_query_unsafe()

LEX_CSTRING thd_query_unsafe ( THD thd)

Get the current query string for the thread.

Parameters
thdThe MySQL internal thread pointer
Returns
query string and length. May be non-null-terminated.
Note
This function is not thread safe and should only be called from the thread owning thd.
See also
thd_query_safe().

◆ thd_set_thread_stack()

void thd_set_thread_stack ( THD thd,
const char *  stack_start 
)

Set thread stack in THD object.

Parameters
thdThread object
stack_startStart of stack to set in THD object

◆ thd_slave_thread()

int thd_slave_thread ( const THD thd)

Check if a user thread is a replication slave thread.

Parameters
thduser thread
Return values
0the user thread is not a replication slave thread
1the user thread is a replication slave thread

◆ thd_sqlcom_can_generate_row_events()

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.

Parameters
thdThread handle
Return values
1the query may generate row changes, 0 otherwise.

◆ thd_thread_id()

my_thread_id thd_thread_id ( const THD thd)