MySQL 8.4.2
Source Code Documentation
srv_session.cc File Reference

class Srv_session implementation. More...

#include "sql/srv_session.h"
#include <stddef.h>
#include <stdio.h>
#include <sys/types.h>
#include <atomic>
#include <list>
#include <map>
#include <new>
#include <utility>
#include "lex_string.h"
#include "m_string.h"
#include "mutex_lock.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_macros.h"
#include "my_psi_config.h"
#include "my_thread.h"
#include "my_thread_local.h"
#include "mysql.h"
#include "mysql/components/my_service.h"
#include "mysql/components/services/bits/mysql_mutex_bits.h"
#include "mysql/components/services/bits/mysql_rwlock_bits.h"
#include "mysql/components/services/bits/psi_bits.h"
#include "mysql/components/services/bits/psi_mutex_bits.h"
#include "mysql/components/services/bits/psi_rwlock_bits.h"
#include "mysql/components/services/log_builtins.h"
#include "mysql/my_loglevel.h"
#include "mysql/plugin_audit.h"
#include "mysql/psi/mysql_mutex.h"
#include "mysql/psi/mysql_rwlock.h"
#include "mysql/psi/mysql_statement.h"
#include "mysql/strings/m_ctype.h"
#include "mysql_time.h"
#include "mysqld_error.h"
#include "nulls.h"
#include "pfs_thread_provider.h"
#include "rwlock_scoped_lock.h"
#include "sql/auth/sql_security_ctx.h"
#include "sql/conn_handler/connection_handler_manager.h"
#include "sql/current_thd.h"
#include "sql/debug_sync.h"
#include "sql/derror.h"
#include "sql/log.h"
#include "sql/mysqld.h"
#include "sql/mysqld_thd_manager.h"
#include "sql/sql_audit.h"
#include "sql/sql_base.h"
#include "sql/sql_class.h"
#include "sql/sql_connect.h"
#include "sql/sql_list.h"
#include "sql/sql_parse.h"
#include "sql/sql_plugin_ref.h"
#include "sql/sql_thd_internal_api.h"
#include "sql/system_variables.h"
#include "thr_mutex.h"

Classes

class  Thread_to_plugin_map
 
class  Mutexed_map_thd_srv_session
 std::map of THD* as key and Srv_session* as value guarded by a read-write lock. More...
 
class  Mutexed_map_thd_srv_session::Do_Impl
 

Functions

void thd_clear_errors (THD *thd)
 Clear errors from the previous THD. More...
 
static int err_start_result_metadata (void *, uint, uint, const CHARSET_INFO *)
 
static int err_field_metadata (void *, struct st_send_field *, const CHARSET_INFO *)
 
static int err_end_result_metadata (void *, uint, uint)
 
static int err_start_row (void *)
 
static int err_end_row (void *)
 
static void err_abort_row (void *)
 
static ulong err_get_client_capabilities (void *)
 
static int err_get_null (void *)
 
static int err_get_integer (void *, longlong)
 
static int err_get_longlong (void *, longlong, uint)
 
static int err_get_decimal (void *, const decimal_t *)
 
static int err_get_double (void *, double, uint32)
 
static int err_get_date (void *, const MYSQL_TIME *)
 
static int err_get_time (void *, const MYSQL_TIME *, uint)
 
static int err_get_datetime (void *, const MYSQL_TIME *, uint)
 
static int err_get_string (void *, const char *, size_t, const CHARSET_INFO *)
 
static void err_handle_ok (void *ctx, uint server_status, uint warn_count, ulonglong affected_rows, ulonglong last_insert_id, const char *const)
 
static void err_handle_error (void *ctx, uint err_errno, const char *err_msg, const char *)
 
static void err_shutdown (void *, int)
 
static bool err_alive (void *)
 
static void set_psi (THD *thd)
 Modifies the PSI structures to (de)install a THD. More...
 
static void close_currently_attached_session_if_any (const st_plugin_int *plugin)
 Looks if there is currently attached session and detaches it. More...
 
static void close_all_sessions_of_plugin_if_any (const st_plugin_int *plugin)
 Looks if the plugin has any non-closed sessions and closes them forcefully. More...
 
static void set_client_port_in_thd (THD *thd, uint16_t *input)
 Callback for inspecting a THD object and modifying the peer_port member. More...
 

Variables

static thread_local const char * THR_stack_start_address = nullptr
 
static thread_local const st_plugin_intTHR_srv_session_thread = nullptr
 
static bool srv_session_THRs_initialized = false
 
static Mutexed_map_thd_srv_session server_session_list
 
static Thread_to_plugin_map server_session_threads
 
const struct st_command_service_cbs error_protocol_callbacks
 

Detailed Description

class Srv_session implementation.

See the method comments for more. Please, check also srv_session.h for more information.

Function Documentation

◆ close_all_sessions_of_plugin_if_any()

static void close_all_sessions_of_plugin_if_any ( const st_plugin_int plugin)
static

Looks if the plugin has any non-closed sessions and closes them forcefully.

Parameters
pluginThe plugin to be checked

◆ close_currently_attached_session_if_any()

static void close_currently_attached_session_if_any ( const st_plugin_int plugin)
static

Looks if there is currently attached session and detaches it.

Parameters
pluginThe plugin to be checked

◆ err_abort_row()

static void err_abort_row ( void *  )
static

◆ err_alive()

static bool err_alive ( void *  )
static

◆ err_end_result_metadata()

static int err_end_result_metadata ( void *  ,
uint  ,
uint   
)
static

◆ err_end_row()

static int err_end_row ( void *  )
static

◆ err_field_metadata()

static int err_field_metadata ( void *  ,
struct st_send_field ,
const CHARSET_INFO  
)
static

◆ err_get_client_capabilities()

static ulong err_get_client_capabilities ( void *  )
static

◆ err_get_date()

static int err_get_date ( void *  ,
const MYSQL_TIME  
)
static

◆ err_get_datetime()

static int err_get_datetime ( void *  ,
const MYSQL_TIME ,
uint   
)
static

◆ err_get_decimal()

static int err_get_decimal ( void *  ,
const decimal_t  
)
static

◆ err_get_double()

static int err_get_double ( void *  ,
double  ,
uint32   
)
static

◆ err_get_integer()

static int err_get_integer ( void *  ,
longlong   
)
static

◆ err_get_longlong()

static int err_get_longlong ( void *  ,
longlong  ,
uint   
)
static

◆ err_get_null()

static int err_get_null ( void *  )
static

◆ err_get_string()

static int err_get_string ( void *  ,
const char *  ,
size_t  ,
const CHARSET_INFO  
)
static

◆ err_get_time()

static int err_get_time ( void *  ,
const MYSQL_TIME ,
uint   
)
static

◆ err_handle_error()

static void err_handle_error ( void *  ctx,
uint  err_errno,
const char *  err_msg,
const char *   
)
static

◆ err_handle_ok()

static void err_handle_ok ( void *  ctx,
uint  server_status,
uint  warn_count,
ulonglong  affected_rows,
ulonglong  last_insert_id,
const char * const   
)
static

◆ err_shutdown()

static void err_shutdown ( void *  ,
int   
)
static

◆ err_start_result_metadata()

static int err_start_result_metadata ( void *  ,
uint  ,
uint  ,
const CHARSET_INFO  
)
static

◆ err_start_row()

static int err_start_row ( void *  )
static

◆ set_client_port_in_thd()

static void set_client_port_in_thd ( THD thd,
uint16_t *  input 
)
static

Callback for inspecting a THD object and modifying the peer_port member.

◆ set_psi()

static void set_psi ( THD thd)
static

Modifies the PSI structures to (de)install a THD.

Parameters
thdTHD

◆ thd_clear_errors()

void thd_clear_errors ( THD thd)

Clear errors from the previous THD.

Parameters
thdTHD object

Variable Documentation

◆ error_protocol_callbacks

const struct st_command_service_cbs error_protocol_callbacks
Initial value:
= {
static int err_field_metadata(void *, struct st_send_field *, const CHARSET_INFO *)
Definition: srv_session.cc:521
static int err_get_date(void *, const MYSQL_TIME *)
Definition: srv_session.cc:546
static void err_shutdown(void *, int)
Definition: srv_session.cc:578
static int err_get_decimal(void *, const decimal_t *)
Definition: srv_session.cc:542
static int err_get_integer(void *, longlong)
Definition: srv_session.cc:538
static ulong err_get_client_capabilities(void *)
Definition: srv_session.cc:534
static int err_get_time(void *, const MYSQL_TIME *, uint)
Definition: srv_session.cc:548
static int err_start_row(void *)
Definition: srv_session.cc:528
static int err_get_null(void *)
Definition: srv_session.cc:536
static int err_get_longlong(void *, longlong, uint)
Definition: srv_session.cc:540
static void err_handle_error(void *ctx, uint err_errno, const char *err_msg, const char *)
Definition: srv_session.cc:570
static void err_handle_ok(void *ctx, uint server_status, uint warn_count, ulonglong affected_rows, ulonglong last_insert_id, const char *const)
Definition: srv_session.cc:556
static void err_abort_row(void *)
Definition: srv_session.cc:532
static int err_get_string(void *, const char *, size_t, const CHARSET_INFO *)
Definition: srv_session.cc:552
static int err_get_double(void *, double, uint32)
Definition: srv_session.cc:544
static int err_get_datetime(void *, const MYSQL_TIME *, uint)
Definition: srv_session.cc:550
static bool err_alive(void *)
Definition: srv_session.cc:580
static int err_start_result_metadata(void *, uint, uint, const CHARSET_INFO *)
Definition: srv_session.cc:517
static int err_end_row(void *)
Definition: srv_session.cc:530
static int err_end_result_metadata(void *, uint, uint)
Definition: srv_session.cc:526

◆ server_session_list

Mutexed_map_thd_srv_session server_session_list
static

◆ server_session_threads

Thread_to_plugin_map server_session_threads
static

◆ srv_session_THRs_initialized

bool srv_session_THRs_initialized = false
static

◆ THR_srv_session_thread

thread_local const st_plugin_int* THR_srv_session_thread = nullptr
static

◆ THR_stack_start_address

thread_local const char* THR_stack_start_address = nullptr
static