MySQL 8.4.0
Source Code Documentation
thread_pool_priv.h File Reference

All accesses to THD variables and functions are defined in this header file. More...

Go to the source code of this file.

Classes

struct  Connection_handler_functions
 This structure must be populated by plugins which implement connection handlers and passed as an argument to my_connection_handler_set() in order to activate the connection handler. More...
 

Typedefs

typedef bool(* add_connection_t) (Channel_info *channel_info)
 Called by the server when a new client connects. More...
 
typedef void(* end_t) (void)
 Called by the server when the connection handler is destroyed. More...
 
typedef void() do_thd_impl_uint64(THD *, uint64)
 

Functions

THDcreate_thd (Channel_info *channel_info)
 
void destroy_channel_info (Channel_info *channel_info)
 
bool connection_events_loop_aborted ()
 
void dec_connection_count ()
 
void inc_thread_created ()
 
void thd_lock_thread_count ()
 
void thd_unlock_thread_count ()
 
void do_for_all_thd (do_thd_impl_uint64, uint64)
 
void * thd_get_scheduler_data (THD *thd)
 Get reference to scheduler data object. More...
 
void thd_set_scheduler_data (THD *thd, void *data)
 Set reference to Scheduler data object for THD object. More...
 
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...
 
void thd_set_killed (THD *thd)
 Set the state on connection to killed. More...
 
void thd_clear_errors (THD *thd)
 Clear errors from the previous THD. More...
 
void thd_close_connection (THD *thd)
 Close the socket used by this connection. More...
 
THDthd_get_current_thd ()
 Get current THD object from thread local data. More...
 
void thd_lock_data (THD *thd)
 Lock data that needs protection in THD object. More...
 
void thd_unlock_data (THD *thd)
 Unlock data that needs protection in THD object. More...
 
bool thd_is_transaction_active (THD *thd)
 Support method to check if connection has already started transaction. More...
 
bool thd_in_active_multi_stmt_transaction (const THD *)
 Predicate for determining if connection is in active multi-statement transaction. More...
 
int thd_connection_has_data (THD *thd)
 Check if there is buffered data on the socket representing the connection. More...
 
void thd_set_net_read_write (THD *thd, uint val)
 Set reading/writing on socket, used by SHOW PROCESSLIST. More...
 
uint thd_get_net_read_write (THD *thd)
 Get reading/writing on socket from THD object. More...
 
void thd_set_not_killable (THD *thd)
 Mark the THD as not killable as it is not currently used by a thread. More...
 
ulong thd_get_net_wait_timeout (THD *thd)
 Get net_wait_timeout for THD object. More...
 
my_socket thd_get_fd (THD *thd)
 Get socket file descriptor for this connection. More...
 
void thd_store_globals (THD *thd)
 Set thread specific environment required for thd cleanup in thread pool. More...
 
bool thd_check_connection_admin_privilege (THD *thd)
 
bool do_command (THD *thd)
 Read one command from connection and execute it (query or simple command). More...
 
bool thd_prepare_connection (THD *thd)
 
void mysql_audit_release (THD *thd)
 Release any resources associated with the current thd. More...
 
bool thd_connection_alive (THD *thd)
 
void close_connection (THD *thd, uint sql_errno, bool server_shutdown, bool generate_event)
 Close a connection. More...
 
void end_connection (THD *thd)
 
void reset_thread_globals (THD *thd)
 Reset thread globals associated. More...
 
ulong get_max_connections (void)
 Get max number of connections. More...
 
my_thread_attr_tget_connection_attrib (void)
 Get thread attributes for connection threads. More...
 
void increment_aborted_connects ()
 

Detailed Description

All accesses to THD variables and functions are defined in this header file.

Typedef Documentation

◆ add_connection_t

typedef bool(* add_connection_t) (Channel_info *channel_info)

Called by the server when a new client connects.

Parameters
channel_infoPointer to object containing information about the new connection.
Return values
truefailure
falsesuccess

◆ do_thd_impl_uint64

typedef void() do_thd_impl_uint64(THD *, uint64)

◆ end_t

typedef void(* end_t) (void)

Called by the server when the connection handler is destroyed.

Function Documentation

◆ close_connection()

void close_connection ( THD thd,
uint  sql_errno,
bool  server_shutdown,
bool  generate_event 
)

Close a connection.

Parameters
thdThread handle.
sql_errnoThe error code to send before disconnect.
server_shutdownTrue for a server shutdown
generate_eventGenerate Audit API disconnect event.
Note
For the connection that is doing shutdown, this is called twice

◆ connection_events_loop_aborted()

bool connection_events_loop_aborted ( )
inline

◆ create_thd()

THD * create_thd ( Channel_info channel_info)

◆ dec_connection_count()

void dec_connection_count ( )

◆ destroy_channel_info()

void destroy_channel_info ( Channel_info channel_info)

◆ do_for_all_thd()

void do_for_all_thd ( do_thd_impl_uint64  f,
uint64  v 
)

◆ end_connection()

void end_connection ( THD thd)

◆ get_connection_attrib()

my_thread_attr_t * get_connection_attrib ( void  )

Get thread attributes for connection threads.

Returns the server connection attribute.

Return values
Referenceto thread attribute for connection threads

◆ get_max_connections()

ulong get_max_connections ( void  )

Get max number of connections.

Return values
Maxnumber of connections for MySQL Server

◆ inc_thread_created()

void inc_thread_created ( )

◆ increment_aborted_connects()

void increment_aborted_connects ( )

◆ mysql_audit_release()

void mysql_audit_release ( THD thd)

Release any resources associated with the current thd.

Parameters
[in]thdCurrent thread

◆ reset_thread_globals()

void reset_thread_globals ( THD thd)

Reset thread globals associated.

Parameters
thdTHD object

◆ thd_check_connection_admin_privilege()

bool thd_check_connection_admin_privilege ( THD thd)

◆ thd_clear_errors()

void thd_clear_errors ( THD thd)

Clear errors from the previous THD.

Parameters
thdTHD object

◆ thd_close_connection()

void thd_close_connection ( THD thd)

Close the socket used by this connection.

Parameters
thdTHD object
Note
Expects lock on thd->LOCK_thd_data.

◆ thd_connection_alive()

bool thd_connection_alive ( THD thd)

◆ thd_connection_has_data()

int thd_connection_has_data ( THD thd)

Check if there is buffered data on the socket representing the connection.

Parameters
thdTHD object

◆ thd_get_current_thd()

THD * thd_get_current_thd ( )

Get current THD object from thread local data.

Return values
TheTHD object for the thread, NULL if not connection thread

◆ thd_get_fd()

my_socket thd_get_fd ( THD thd)

Get socket file descriptor for this connection.

Parameters
thdTHD object
Return values
Socketof the connection

◆ thd_get_net_read_write()

uint thd_get_net_read_write ( THD thd)

Get reading/writing on socket from THD object.

Parameters
thdTHD object
Return values
net.reading_or_writingvalue for thread on THD.

◆ thd_get_net_wait_timeout()

ulong thd_get_net_wait_timeout ( THD thd)

Get net_wait_timeout for THD object.

Parameters
thdTHD object
Return values
net_wait_timeoutvalue for thread on THD

◆ 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_get_scheduler_data()

void * thd_get_scheduler_data ( THD thd)

Get reference to scheduler data object.

Parameters
thdTHD object
Return values
Schedulerdata object on THD

◆ thd_in_active_multi_stmt_transaction()

bool thd_in_active_multi_stmt_transaction ( const THD thd)

Predicate for determining if connection is in active multi-statement transaction.

◆ thd_is_transaction_active()

bool thd_is_transaction_active ( THD thd)

Support method to check if connection has already started transaction.

Parameters
thdCurrent thread
Return values
trueif connection already started transaction

◆ thd_lock_data()

void thd_lock_data ( THD thd)

Lock data that needs protection in THD object.

Parameters
thdTHD object

◆ thd_lock_thread_count()

void thd_lock_thread_count ( )

◆ thd_prepare_connection()

bool thd_prepare_connection ( THD thd)

◆ thd_set_killed()

void thd_set_killed ( THD thd)

Set the state on connection to killed.

Parameters
thdTHD object

◆ thd_set_net_read_write()

void thd_set_net_read_write ( THD thd,
uint  val 
)

Set reading/writing on socket, used by SHOW PROCESSLIST.

Parameters
thdTHD object
valValue to set it to (0 or 1)

◆ thd_set_not_killable()

void thd_set_not_killable ( THD thd)

Mark the THD as not killable as it is not currently used by a thread.

Parameters
thdTHD object

◆ 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_scheduler_data()

void thd_set_scheduler_data ( THD thd,
void *  data 
)

Set reference to Scheduler data object for THD object.

Parameters
thdTHD object
dataScheduler data object to set on THD

◆ thd_store_globals()

void thd_store_globals ( THD thd)

Set thread specific environment required for thd cleanup in thread pool.

Parameters
thdTHD object

◆ thd_unlock_data()

void thd_unlock_data ( THD thd)

Unlock data that needs protection in THD object.

Parameters
thdTHD object

◆ thd_unlock_thread_count()

void thd_unlock_thread_count ( )