MySQL 9.1.0
Source Code Documentation
sql_connect.cc File Reference
#include "sql/sql_connect.h"
#include "my_config.h"
#include "my_psi_config.h"
#include "mysql/components/services/log_builtins.h"
#include "mysql/components/services/log_shared.h"
#include "mysql/my_loglevel.h"
#include "pfs_thread_provider.h"
#include "sql/table.h"
#include <netdb.h>
#include <netinet/in.h>
#include <stdint.h>
#include <string.h>
#include <sys/socket.h>
#include <algorithm>
#include <atomic>
#include <memory>
#include <string>
#include <unordered_map>
#include <utility>
#include "lex_string.h"
#include "m_string.h"
#include "map_helpers.h"
#include "my_command.h"
#include "my_dbug.h"
#include "my_sqlcommand.h"
#include "my_sys.h"
#include "mysql/plugin_audit.h"
#include "mysql/psi/mysql_mutex.h"
#include "mysql/psi/mysql_thread.h"
#include "mysql/service_mysql_alloc.h"
#include "mysql/strings/m_ctype.h"
#include "mysql_com.h"
#include "mysqld_error.h"
#include "sql-common/net_ns.h"
#include "sql/auth/auth_acls.h"
#include "sql/auth/auth_common.h"
#include "sql/auth/sql_security_ctx.h"
#include "sql/debug_sync.h"
#include "sql/derror.h"
#include "sql/hostname_cache.h"
#include "sql/item_func.h"
#include "sql/log.h"
#include "sql/mysqld.h"
#include "sql/protocol.h"
#include "sql/protocol_classic.h"
#include "sql/psi_memory_key.h"
#include "sql/sql_audit.h"
#include "sql/sql_class.h"
#include "sql/sql_error.h"
#include "sql/sql_lex.h"
#include "sql/sql_parse.h"
#include "sql/sql_plugin.h"
#include "sql/system_variables.h"
#include "sql_string.h"
#include "string_with_len.h"
#include "violite.h"
#include <arpa/inet.h>

Macros

#define SSL_HANDSHAKE_SIZE   2
 
#define NORMAL_HANDSHAKE_SIZE   6
 
#define MIN_HANDSHAKE_SIZE   2
 

Functions

int get_or_create_user_conn (THD *thd, const char *user, const char *host, const USER_RESOURCES *mqh)
 
int check_for_max_user_connections (THD *thd, const USER_CONN *uc)
 
void decrease_user_connections (USER_CONN *uc)
 
void release_user_connection (THD *thd)
 
bool check_mqh (THD *thd, uint check_command)
 
void init_max_user_conn (void)
 
void free_max_user_conn (void)
 
void reset_mqh (THD *thd, LEX_USER *lu, bool get_them=false)
 
bool thd_init_client_charset (THD *thd, uint cs_number)
 Set thread character set variables from the given ID. More...
 
static int check_connection (THD *thd)
 
static bool login_connection (THD *thd)
 
void end_connection (THD *thd)
 
static void prepare_new_connection_state (THD *thd)
 
bool thd_prepare_connection (THD *thd)
 
void close_connection (THD *thd, uint sql_errno, bool server_shutdown, bool generate_event)
 Close a connection. More...
 
bool thd_connection_alive (THD *thd)
 

Variables

static collation_unordered_map< std::string, unique_ptr_my_free< user_conn > > * hash_user_connections
 

Macro Definition Documentation

◆ MIN_HANDSHAKE_SIZE

#define MIN_HANDSHAKE_SIZE   2

◆ NORMAL_HANDSHAKE_SIZE

#define NORMAL_HANDSHAKE_SIZE   6

◆ SSL_HANDSHAKE_SIZE

#define SSL_HANDSHAKE_SIZE   2

Function Documentation

◆ check_connection()

static int check_connection ( THD thd)
static

◆ check_for_max_user_connections()

int check_for_max_user_connections ( THD thd,
const USER_CONN uc 
)

◆ check_mqh()

bool check_mqh ( THD thd,
uint  check_command 
)

◆ 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

◆ decrease_user_connections()

void decrease_user_connections ( USER_CONN uc)

◆ end_connection()

void end_connection ( THD thd)

◆ free_max_user_conn()

void free_max_user_conn ( void  )

◆ get_or_create_user_conn()

int get_or_create_user_conn ( THD thd,
const char *  user,
const char *  host,
const USER_RESOURCES mqh 
)

◆ init_max_user_conn()

void init_max_user_conn ( void  )

◆ login_connection()

static bool login_connection ( THD thd)
static

◆ prepare_new_connection_state()

static void prepare_new_connection_state ( THD thd)
static

◆ release_user_connection()

void release_user_connection ( THD thd)

◆ reset_mqh()

void reset_mqh ( THD thd,
LEX_USER lu,
bool  get_them = false 
)

◆ thd_connection_alive()

bool thd_connection_alive ( THD thd)

◆ thd_init_client_charset()

bool thd_init_client_charset ( THD thd,
uint  cs_number 
)

Set thread character set variables from the given ID.

Parameters
thdthread handle
cs_numbercharacter set and collation ID
Return values
0OK; character_set_client, collation_connection and character_set_results are set to the new value, or to the default global values.
1error, e.g. the given ID is not supported by parser. Corresponding SQL error is sent.

◆ thd_prepare_connection()

bool thd_prepare_connection ( THD thd)

Variable Documentation

◆ hash_user_connections

collation_unordered_map<std::string, unique_ptr_my_free<user_conn> >* hash_user_connections
static