MySQL 9.1.0
Source Code Documentation
sql_servers.cc File Reference
#include "sql/sql_servers.h"
#include <stdlib.h>
#include <string.h>
#include <atomic>
#include <memory>
#include <string>
#include <unordered_map>
#include <utility>
#include "m_string.h"
#include "map_helpers.h"
#include "my_alloc.h"
#include "my_base.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_macros.h"
#include "my_psi_config.h"
#include "my_sys.h"
#include "mysql/components/services/bits/mysql_rwlock_bits.h"
#include "mysql/components/services/bits/psi_bits.h"
#include "mysql/components/services/bits/psi_memory_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/psi/mysql_memory.h"
#include "mysql/psi/mysql_mutex.h"
#include "mysql/psi/mysql_rwlock.h"
#include "mysql/strings/m_ctype.h"
#include "mysqld_error.h"
#include "sql/auth/auth_acls.h"
#include "sql/auth/auth_common.h"
#include "sql/field.h"
#include "sql/handler.h"
#include "sql/iterators/row_iterator.h"
#include "sql/psi_memory_key.h"
#include "sql/sql_backup_lock.h"
#include "sql/sql_base.h"
#include "sql/sql_class.h"
#include "sql/sql_const.h"
#include "sql/sql_error.h"
#include "sql/sql_executor.h"
#include "sql/sql_system_table_check.h"
#include "sql/system_variables.h"
#include "sql/table.h"
#include "sql/thd_raii.h"
#include "sql/thr_malloc.h"
#include "sql/transaction.h"
#include "string_with_len.h"
#include "thr_lock.h"

Enumerations

enum  enum_servers_table_field {
  SERVERS_FIELD_NAME = 0 , SERVERS_FIELD_HOST , SERVERS_FIELD_DB , SERVERS_FIELD_USERNAME ,
  SERVERS_FIELD_PASSWORD , SERVERS_FIELD_PORT , SERVERS_FIELD_SOCKET , SERVERS_FIELD_SCHEME ,
  SERVERS_FIELD_OWNER
}
 This enum describes the structure of the mysql.servers table. More...
 

Functions

static bool get_server_from_table_to_cache (TABLE *table)
 
static void init_servers_cache_psi_keys (void)
 
bool servers_init (THD *thd)
 
static bool servers_load (THD *thd, TABLE *table)
 
bool servers_reload (THD *thd)
 
static bool close_cached_connection_tables (THD *thd, const char *connection_string, size_t connection_length)
 Close all tables which match specified connection string or if specified string is NULL, then any table with a connection string. More...
 
static void store_new_field (TABLE *table, enum_servers_table_field field, const LEX_STRING *val)
 Helper function for creating a record for inserting a new server into the mysql.servers table. More...
 
static void store_updated_field (TABLE *table, enum_servers_table_field field, const char *existing_val, const LEX_STRING *new_val)
 Helper function for creating a record for updating an existing server in the mysql.servers table. More...
 
void servers_free (bool end)
 
static FOREIGN_SERVERclone_server (MEM_ROOT *mem, const FOREIGN_SERVER *server, FOREIGN_SERVER *buffer)
 
FOREIGN_SERVERget_server_by_name (MEM_ROOT *mem, const char *server_name, FOREIGN_SERVER *buff)
 

Variables

static collation_unordered_map< std::string, FOREIGN_SERVER * > * servers_cache
 
static MEM_ROOT mem
 
static mysql_rwlock_t THR_LOCK_servers
 
static const int MYSQL_SERVERS_TABLE_FIELD_COUNT = 9
 
static const TABLE_FIELD_TYPE mysql_servers_table_fields [MYSQL_SERVERS_TABLE_FIELD_COUNT]
 
static const TABLE_FIELD_DEF mysql_servers_table_def
 
static PSI_rwlock_key key_rwlock_THR_LOCK_servers
 
static PSI_rwlock_info all_servers_cache_rwlocks []
 
static PSI_memory_info all_servers_cache_memory []
 

Enumeration Type Documentation

◆ enum_servers_table_field

This enum describes the structure of the mysql.servers table.

Enumerator
SERVERS_FIELD_NAME 
SERVERS_FIELD_HOST 
SERVERS_FIELD_DB 
SERVERS_FIELD_USERNAME 
SERVERS_FIELD_PASSWORD 
SERVERS_FIELD_PORT 
SERVERS_FIELD_SOCKET 
SERVERS_FIELD_SCHEME 
SERVERS_FIELD_OWNER 

Function Documentation

◆ clone_server()

static FOREIGN_SERVER * clone_server ( MEM_ROOT mem,
const FOREIGN_SERVER server,
FOREIGN_SERVER buffer 
)
static

◆ close_cached_connection_tables()

static bool close_cached_connection_tables ( THD thd,
const char *  connection_string,
size_t  connection_length 
)
static

Close all tables which match specified connection string or if specified string is NULL, then any table with a connection string.

◆ get_server_by_name()

FOREIGN_SERVER * get_server_by_name ( MEM_ROOT mem,
const char *  server_name,
FOREIGN_SERVER buff 
)

◆ get_server_from_table_to_cache()

static bool get_server_from_table_to_cache ( TABLE table)
static

◆ init_servers_cache_psi_keys()

static void init_servers_cache_psi_keys ( void  )
static

◆ servers_free()

void servers_free ( bool  end)

◆ servers_init()

bool servers_init ( THD thd)

◆ servers_load()

static bool servers_load ( THD thd,
TABLE table 
)
static

◆ servers_reload()

bool servers_reload ( THD thd)

◆ store_new_field()

static void store_new_field ( TABLE table,
enum_servers_table_field  field,
const LEX_STRING val 
)
inlinestatic

Helper function for creating a record for inserting a new server into the mysql.servers table.

Set a field to the given parser string. If the parser string is empty, set the field to "" instead.

◆ store_updated_field()

static void store_updated_field ( TABLE table,
enum_servers_table_field  field,
const char *  existing_val,
const LEX_STRING new_val 
)
inlinestatic

Helper function for creating a record for updating an existing server in the mysql.servers table.

Set a field to the given parser string unless the parser string is empty or equal to the existing value.

Variable Documentation

◆ all_servers_cache_memory

PSI_memory_info all_servers_cache_memory[]
static
Initial value:
= {
"Cache infrastructure and mem root for servers cache."}}
#define PSI_FLAG_ONLY_GLOBAL_STAT
Global stat only flag.
Definition: psi_bits.h:112
PSI_memory_key key_memory_servers
Definition: psi_memory_key.cc:136

◆ all_servers_cache_rwlocks

PSI_rwlock_info all_servers_cache_rwlocks[]
static
Initial value:
= {
#define PSI_DOCUMENT_ME
Definition: component_common.h:29
#define PSI_FLAG_SINGLETON
Singleton flag.
Definition: component_common.h:35
static PSI_rwlock_key key_rwlock_THR_LOCK_servers
Definition: sql_servers.cc:151

◆ key_rwlock_THR_LOCK_servers

PSI_rwlock_key key_rwlock_THR_LOCK_servers
static

◆ mem

MEM_ROOT mem
static

◆ mysql_servers_table_def

const TABLE_FIELD_DEF mysql_servers_table_def
static
Initial value:
= {
static const TABLE_FIELD_TYPE mysql_servers_table_fields[MYSQL_SERVERS_TABLE_FIELD_COUNT]
Definition: sql_servers.cc:121
static const int MYSQL_SERVERS_TABLE_FIELD_COUNT
Definition: sql_servers.cc:119

◆ MYSQL_SERVERS_TABLE_FIELD_COUNT

const int MYSQL_SERVERS_TABLE_FIELD_COUNT = 9
static

◆ mysql_servers_table_fields

const TABLE_FIELD_TYPE mysql_servers_table_fields[MYSQL_SERVERS_TABLE_FIELD_COUNT]
static
Initial value:
= {
{{STRING_WITH_LEN("Server_name")},
{STRING_WITH_LEN("char(64)")},
{nullptr, 0}},
{{STRING_WITH_LEN("Host")},
{STRING_WITH_LEN("char(255)")},
{STRING_WITH_LEN("ascii")}},
{{STRING_WITH_LEN("Db")}, {STRING_WITH_LEN("char(64)")}, {nullptr, 0}},
{{STRING_WITH_LEN("Username")},
{STRING_WITH_LEN("char(64)")},
{nullptr, 0}},
{{STRING_WITH_LEN("Password")},
{STRING_WITH_LEN("char(64)")},
{nullptr, 0}},
{{STRING_WITH_LEN("Port")}, {STRING_WITH_LEN("int")}, {nullptr, 0}},
{{STRING_WITH_LEN("Socket")},
{STRING_WITH_LEN("char(64)")},
{nullptr, 0}},
{{STRING_WITH_LEN("Wrapper")},
{STRING_WITH_LEN("char(64)")},
{nullptr, 0}},
{{STRING_WITH_LEN("Owner")},
{STRING_WITH_LEN("char(64)")},
{nullptr, 0}}}
#define STRING_WITH_LEN(X)
Definition: string_with_len.h:29

◆ servers_cache

collation_unordered_map<std::string, FOREIGN_SERVER *>* servers_cache
static

◆ THR_LOCK_servers

mysql_rwlock_t THR_LOCK_servers
static