MySQL  8.0.27
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_ctype.h"
#include "m_string.h"
#include "mutex_lock.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_loglevel.h"
#include "my_macros.h"
#include "my_psi_config.h"
#include "my_thread.h"
#include "my_thread_local.h"
#include "mysql/components/services/bits/psi_bits.h"
#include "mysql/components/services/log_builtins.h"
#include "mysql/components/services/mysql_mutex_bits.h"
#include "mysql/components/services/mysql_rwlock_bits.h"
#include "mysql/components/services/psi_mutex_bits.h"
#include "mysql/components/services/psi_rwlock_bits.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_time.h"
#include "mysqld_error.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)
 
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)

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:508
static int err_get_date(void *, const MYSQL_TIME *)
Definition: srv_session.cc:533
static void err_shutdown(void *, int)
Definition: srv_session.cc:565
static int err_get_decimal(void *, const decimal_t *)
Definition: srv_session.cc:529
static int err_get_integer(void *, longlong)
Definition: srv_session.cc:525
static ulong err_get_client_capabilities(void *)
Definition: srv_session.cc:521
static int err_get_time(void *, const MYSQL_TIME *, uint)
Definition: srv_session.cc:535
static int err_start_row(void *)
Definition: srv_session.cc:515
static int err_get_null(void *)
Definition: srv_session.cc:523
static int err_get_longlong(void *, longlong, uint)
Definition: srv_session.cc:527
static void err_handle_error(void *ctx, uint err_errno, const char *err_msg, const char *)
Definition: srv_session.cc:557
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:543
static void err_abort_row(void *)
Definition: srv_session.cc:519
static int err_get_string(void *, const char *, size_t, const CHARSET_INFO *)
Definition: srv_session.cc:539
static int err_get_double(void *, double, uint32)
Definition: srv_session.cc:531
static int err_get_datetime(void *, const MYSQL_TIME *, uint)
Definition: srv_session.cc:537
static bool err_alive(void *)
Definition: srv_session.cc:567
static int err_start_result_metadata(void *, uint, uint, const CHARSET_INFO *)
Definition: srv_session.cc:504
static int err_end_row(void *)
Definition: srv_session.cc:517
static int err_end_result_metadata(void *, uint, uint)
Definition: srv_session.cc:513

◆ 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