MySQL  8.0.17
Source Code Documentation
set_var.cc File Reference
#include "sql/set_var.h"
#include <string.h>
#include <sys/types.h>
#include <cstdlib>
#include <utility>
#include "m_ctype.h"
#include "m_string.h"
#include "map_helpers.h"
#include "my_dbug.h"
#include "my_io.h"
#include "my_loglevel.h"
#include "my_sys.h"
#include "mysql/components/services/log_builtins.h"
#include "mysql/components/services/log_shared.h"
#include "mysql/plugin_audit.h"
#include "mysql/psi/mysql_mutex.h"
#include "mysql/psi/mysql_rwlock.h"
#include "mysql/psi/psi_base.h"
#include "mysqld_error.h"
#include "sql/auth/auth_acls.h"
#include "sql/auth/auth_common.h"
#include "sql/auth/sql_security_ctx.h"
#include "sql/derror.h"
#include "sql/enum_query_type.h"
#include "sql/item.h"
#include "sql/item_func.h"
#include "sql/log.h"
#include "sql/mysqld.h"
#include "sql/persisted_variable.h"
#include "sql/protocol_classic.h"
#include "sql/session_tracker.h"
#include "sql/sql_audit.h"
#include "sql/sql_base.h"
#include "sql/sql_class.h"
#include "sql/sql_error.h"
#include "sql/sql_lex.h"
#include "sql/sql_list.h"
#include "sql/sql_parse.h"
#include "sql/sql_select.h"
#include "sql/sql_show.h"
#include "sql/sys_vars_shared.h"
#include "sql/system_variables.h"
#include "sql/table.h"
#include "sql_string.h"

Classes

struct  my_old_conv
 

Functions

collation_unordered_map< string, sys_var * > * get_system_variable_hash (void)
 
bool get_sysvar_source (const char *name, uint length, enum enum_variable_source *source)
 Get source of a given system variable given its name and name length. More...
 
int sys_var_init ()
 
int sys_var_add_options (std::vector< my_option > *long_options, int parse_flags)
 
void sys_var_end ()
 
bool check_priv (THD *thd, bool static_variable)
 This function will check for necessary privileges needed to perform RESET PERSIST or SET PERSIST[_ONLY] operation. More...
 
bool throw_bounds_warning (THD *thd, const char *name, bool fixed, bool is_unsigned, longlong v)
 Throw warning (error in STRICT mode) if value for variable needed bounding. More...
 
bool throw_bounds_warning (THD *thd, const char *name, bool fixed, double v)
 
const CHARSET_INFOget_old_charset_by_name (const char *name)
 
int mysql_add_sys_var_chain (sys_var *first)
 Add variables to the dynamic hash of system variables. More...
 
int mysql_del_sys_var_chain (sys_var *first)
 
static int show_cmp (const void *a, const void *b)
 
ulong get_system_variable_hash_records (void)
 
ulonglong get_system_variable_hash_version (void)
 
bool enumerate_sys_vars (Show_var_array *show_var_array, bool sort, enum enum_var_type query_scope, bool strict)
 Constructs an array of system variables for display to the user. More...
 
sys_varintern_find_sys_var (const char *str, size_t length)
 Find a user set-table variable. More...
 
int sql_set_variables (THD *thd, List< set_var_base > *var_list, bool opened)
 Execute update of all variables. More...
 
bool keyring_access_test ()
 This function is used to check if key management UDFs like keying_key_generate/store/remove should proceed or not. More...
 
static bool can_persist_non_persistent_var (THD *thd, sys_var *var, enum_var_type setvar_type)
 Checks if a THD can set non-persist variables. More...
 

Variables

static collation_unordered_map< string, sys_var * > * system_variable_hash
 
static PolyLock_mutex PLock_global_system_variables & LOCK_global_system_variables
 
ulonglong system_variable_hash_version = 0
 
static collation_unordered_set< string > * never_persistable_vars
 list of variables that shouldn't be persisted in all cases More...
 
sys_var_chain all_sys_vars = {NULL, NULL}
 
static my_old_conv old_conv []
 
char * sys_var_persist_only_admin_x509_subject = NULL
 global X509 subject name to require from the client session to allow SET PERSIST[_ONLY] on sys_var::NOTPERSIST variables More...
 

Function Documentation

◆ can_persist_non_persistent_var()

static bool can_persist_non_persistent_var ( THD thd,
sys_var var,
enum_var_type  setvar_type 
)
static

Checks if a THD can set non-persist variables.

Requires that: the session uses SSL the peer has presented a valid certificate the certificate has a certain subject name

The format checked is deliberately kept the same as the other SSL system and status variables representing names. Hence X509_NAME_oneline is used.

Return values
truethe THD can set NON_PERSIST variables
falseusual restrictions apply
Parameters
thdthe THD handle
varthe variable to be set
setvar_typethe operation to check against.
See also
sys_variables_admin_dn

◆ check_priv()

bool check_priv ( THD thd,
bool  static_variable 
)

This function will check for necessary privileges needed to perform RESET PERSIST or SET PERSIST[_ONLY] operation.

Parameters
[in]thdPointer to connection handle.
[in]static_variabledescribes if variable is static or dynamic
Returns
0 Success
1 Failure

◆ enumerate_sys_vars()

bool enumerate_sys_vars ( Show_var_array show_var_array,
bool  sort,
enum enum_var_type  query_scope,
bool  strict 
)

Constructs an array of system variables for display to the user.

Parameters
show_var_arrayPrealloced_array of SHOW_VAR elements for display
sortIf true, the system variables should be sorted
query_scopeOPT_GLOBAL or OPT_SESSION for SHOW GLOBAL|SESSION VARIABLES
strictUse strict scope checking
Return values
Trueon error, false otherwise

◆ get_old_charset_by_name()

const CHARSET_INFO* get_old_charset_by_name ( const char *  name)

◆ get_system_variable_hash()

collation_unordered_map<string, sys_var *>* get_system_variable_hash ( void  )

◆ get_system_variable_hash_records()

ulong get_system_variable_hash_records ( void  )

◆ get_system_variable_hash_version()

ulonglong get_system_variable_hash_version ( void  )

◆ get_sysvar_source()

bool get_sysvar_source ( const char *  name,
uint  length,
enum enum_variable_source source 
)

Get source of a given system variable given its name and name length.

◆ intern_find_sys_var()

sys_var* intern_find_sys_var ( const char *  str,
size_t  length 
)

Find a user set-table variable.

Parameters
strName of system variable to find
lengthLength of variable. zero means that we should use strlen() on the variable
Return values
pointerpointer to variable definitions
0Unknown variable (error message is given)

◆ keyring_access_test()

bool keyring_access_test ( )

This function is used to check if key management UDFs like keying_key_generate/store/remove should proceed or not.

If global variable @keyring_operations is OFF then above said udfs will fail.

Returns
Operation status
Return values
0OK
1ERROR, keyring operations are not allowed
See also
Sys_keyring_operations

◆ mysql_add_sys_var_chain()

int mysql_add_sys_var_chain ( sys_var first)

Add variables to the dynamic hash of system variables.

Parameters
firstPointer to first system variable to add
Return values
0SUCCESS
otherwiseFAILURE

◆ mysql_del_sys_var_chain()

int mysql_del_sys_var_chain ( sys_var first)

◆ show_cmp()

static int show_cmp ( const void *  a,
const void *  b 
)
static

◆ sql_set_variables()

int sql_set_variables ( THD thd,
List< set_var_base > *  var_list,
bool  opened 
)

Execute update of all variables.

First run a check of all variables that all updates will go ok. If yes, then execute all updates, returning an error if any one failed.

This should ensure that in all normal cases none all or variables are updated.

Parameters
thdThread id
var_listList of variables to update
openedTrue means tables are open and this function will lock them.
Return values
0ok
1ERROR, message sent (normally no variables was updated)
-1ERROR, message not sent

◆ sys_var_add_options()

int sys_var_add_options ( std::vector< my_option > *  long_options,
int  parse_flags 
)

◆ sys_var_end()

void sys_var_end ( void  )

◆ sys_var_init()

int sys_var_init ( )

◆ throw_bounds_warning() [1/2]

bool throw_bounds_warning ( THD thd,
const char *  name,
bool  fixed,
bool  is_unsigned,
longlong  v 
)

Throw warning (error in STRICT mode) if value for variable needed bounding.

Plug-in interface also uses this.

Parameters
thdthread handle
namevariable's name
fixeddid we have to correct the value? (throw warn/err if so)
is_unsignedis value's type unsigned?
vvariable's value
Return values
trueon error, false otherwise (warning or ok)

◆ throw_bounds_warning() [2/2]

bool throw_bounds_warning ( THD thd,
const char *  name,
bool  fixed,
double  v 
)

Variable Documentation

◆ all_sys_vars

sys_var_chain all_sys_vars = {NULL, NULL}

◆ LOCK_global_system_variables

PolyLock_mutex PLock_global_system_variables & LOCK_global_system_variables
static

◆ never_persistable_vars

collation_unordered_set<string>* never_persistable_vars
static

list of variables that shouldn't be persisted in all cases

◆ old_conv

my_old_conv old_conv[]
static
Initial value:
= {{"cp1251_koi8", "cp1251"},
{"cp1250_latin2", "cp1250"},
{"kam_latin2", "keybcs2"},
{"mac_latin2", "MacRoman"},
{"macce_latin2", "MacCE"},
{"pc2_latin2", "pclatin2"},
{"vga_latin2", "pclatin1"},
{"koi8_cp1251", "koi8r"},
{"win1251ukr_koi8_ukr", "win1251ukr"},
{"koi8_ukr_win1251ukr", "koi8u"},
{NULL, NULL}}
Sergei Dialog Client Authentication NULL
Definition: dialog.cc:352

◆ sys_var_persist_only_admin_x509_subject

char* sys_var_persist_only_admin_x509_subject = NULL

global X509 subject name to require from the client session to allow SET PERSIST[_ONLY] on sys_var::NOTPERSIST variables

See also
set_var::resolve

◆ system_variable_hash

collation_unordered_map<string, sys_var *>* system_variable_hash
static

◆ system_variable_hash_version

ulonglong system_variable_hash_version = 0