MySQL 8.0.39
Source Code Documentation
sys_var Class Referenceabstract

A class representing one system variable - that is something that can be accessed as @global.variable_name or @session.variable_name, visible in SHOW xxx VARIABLES and in INFORMATION_SCHEMA.xxx_VARIABLES, optionally it can be assigned to, optionally it can have a command-line counterpart with the same name. More...

#include <set_var.h>

Inheritance diagram for sys_var:
[legend]

Public Types

enum  flag_enum {
  GLOBAL = 0x0001 , SESSION = 0x0002 , ONLY_SESSION = 0x0004 , SCOPE_MASK = 0x03FF ,
  READONLY = 0x0400 , ALLOCATED = 0x0800 , INVISIBLE = 0x1000 , TRI_LEVEL = 0x2000 ,
  NOTPERSIST = 0x4000 , HINT_UPDATEABLE = 0x8000 , PERSIST_AS_READ_ONLY = 0x10000 , SENSITIVE = 0x20000
}
 
enum  binlog_status_enum { VARIABLE_NOT_IN_BINLOG , SESSION_VARIABLE_IN_BINLOG }
 Enumeration type to indicate for a system variable whether it will be written to the binlog or not. More...
 

Public Member Functions

 sys_var (sys_var_chain *chain, const char *name_arg, const char *comment, int flag_args, ptrdiff_t off, int getopt_id, enum get_opt_arg_type getopt_arg_type, SHOW_TYPE show_val_type_arg, longlong def_val, PolyLock *lock, enum binlog_status_enum binlog_status_arg, on_check_function on_check_func, on_update_function on_update_func, const char *substitute, int parse_flag, sys_var *persisted_alias=nullptr, bool is_persisted_deprecated=false)
 sys_var constructor More...
 
virtual ~sys_var ()=default
 
const char * get_deprecation_substitute ()
 
virtual void cleanup ()
 All the cleanup procedures should be performed here. More...
 
virtual sys_var_pluginvarcast_pluginvar ()
 downcast for sys_var_pluginvar. More...
 
bool check (THD *thd, set_var *var)
 
const ucharvalue_ptr (THD *running_thd, THD *target_thd, enum_var_type type, std::string_view keycache_name)
 
const ucharvalue_ptr (THD *thd, enum_var_type type, std::string_view keycache_name)
 
virtual void update_default (longlong new_def_value)
 
virtual longlong get_default ()
 
virtual longlong get_min_value ()
 
virtual ulonglong get_max_value ()
 
virtual ulong get_var_type ()
 Returns variable type. More...
 
virtual void set_arg_source (get_opt_arg_source *)
 
virtual void set_is_plugin (bool)
 
virtual enum_variable_source get_source ()
 
virtual const char * get_source_name ()
 
virtual void set_source (enum_variable_source src)
 
virtual bool set_source_name (const char *path)
 
virtual bool set_user (const char *usr)
 
virtual const char * get_user ()
 
virtual const char * get_host ()
 
virtual bool set_host (const char *hst)
 
virtual ulonglong get_timestamp () const
 
virtual void set_user_host (THD *thd)
 
my_optionget_option ()
 
virtual void set_timestamp ()
 
virtual void set_timestamp (ulonglong ts)
 
virtual bool is_non_persistent ()
 
bool set_default (THD *thd, set_var *var)
 Update the system variable with the default value from either session or global scope. More...
 
bool update (THD *thd, set_var *var)
 
virtual void saved_value_to_string (THD *thd, set_var *var, char *def_val)=0
 This function converts value stored in save_result to string. More...
 
SHOW_TYPE show_type ()
 
int scope () const
 
const CHARSET_INFOcharset (THD *thd)
 
bool is_readonly () const
 
bool not_visible () const
 
bool is_trilevel () const
 
bool is_persist_readonly () const
 
bool is_parse_early () const
 
bool is_sensitive () const
 
bool is_hint_updateable () const
 Check if the variable can be set using SET_VAR hint. More...
 
bool is_struct ()
 the following is only true for keycache variables, that support the syntax @keycache_name.variable_name More...
 
bool is_written_to_binlog (enum_var_type type)
 
virtual bool check_update_type (Item_result type)=0
 
bool check_scope (enum_var_type query_type)
 Return true for success if: Global query and variable scope is GLOBAL or SESSION, or Session query and variable scope is SESSION or ONLY_SESSION. More...
 
bool is_global_persist (enum_var_type type)
 
bool is_settable_at_command_line ()
 Return true if settable at the command line. More...
 
bool register_option (std::vector< my_option > *array, int parse_flags)
 
void do_deprecated_warning (THD *thd)
 
Itemcopy_value (THD *thd)
 Create item from system variable value. More...
 
void save_default (THD *thd, set_var *var)
 
bool check_if_sensitive_in_context (THD *, bool suppress_errors=true) const
 

Public Attributes

sys_varnext
 
LEX_CSTRING name
 
sys_varm_persisted_alias
 If the variable has an alias in the persisted variables file, this should point to it. More...
 
bool m_is_persisted_deprecated
 If m_persist_alias is set, and the current variable is deprecated and m_persist_alias is the recommended substitute, then this flag should be set to true. More...
 
enum sys_var::binlog_status_enum binlog_status
 

Static Public Attributes

static const int PARSE_EARLY = 1
 
static const int PARSE_NORMAL = 2
 

Protected Types

typedef bool(* on_check_function) (sys_var *self, THD *thd, set_var *var)
 
typedef bool(* pre_update_function) (sys_var *self, THD *thd, set_var *var)
 
typedef bool(* on_update_function) (sys_var *self, THD *thd, enum_var_type type)
 

Protected Member Functions

virtual const ucharsession_value_ptr (THD *running_thd, THD *target_thd, std::string_view keycache_name)
 A pointer to a value of the variable for SHOW. More...
 
virtual const ucharglobal_value_ptr (THD *thd, std::string_view keycache_name)
 
ucharsession_var_ptr (THD *thd)
 A pointer to a storage area of the variable, to the raw data. More...
 
ucharglobal_var_ptr ()
 

Protected Attributes

int flags
 or'ed flag_enum values More...
 
int m_parse_flag
 either PARSE_EARLY or PARSE_NORMAL. More...
 
const SHOW_TYPE show_val_type
 what value_ptr() returns for sql_show.cc More...
 
my_option option
 min, max, default values are stored here More...
 
PolyLockguard
 second lock that protects the variable More...
 
ptrdiff_t offset
 offset to the value from global_system_variables More...
 
on_check_function on_check
 
pre_update_function pre_update
 Pointer to function to be invoked before updating system variable (but after calling on_check hook), while we do not hold any locks yet. More...
 
on_update_function on_update
 
const char *const deprecation_substitute
 
bool is_os_charset
 true if the value is in character_set_filesystem More...
 
struct get_opt_arg_source source
 
char user [USERNAME_CHAR_LENGTH+1]
 
char host [HOSTNAME_LENGTH+1]
 
ulonglong timestamp
 

Private Member Functions

virtual bool do_check (THD *thd, set_var *var)=0
 
virtual void session_save_default (THD *thd, set_var *var)=0
 save the session default value of the variable in var More...
 
virtual void global_save_default (THD *thd, set_var *var)=0
 save the global default value of the variable in var More...
 
virtual bool session_update (THD *thd, set_var *var)=0
 
virtual bool global_update (THD *thd, set_var *var)=0
 

Static Private Member Functions

static bool set_and_truncate (char *dst, const char *string, size_t sizeof_dst)
 Like strncpy, but ensures the destination is '\0'-terminated. More...
 

Friends

class Sys_var_alias
 

Detailed Description

A class representing one system variable - that is something that can be accessed as @global.variable_name or @session.variable_name, visible in SHOW xxx VARIABLES and in INFORMATION_SCHEMA.xxx_VARIABLES, optionally it can be assigned to, optionally it can have a command-line counterpart with the same name.

Member Typedef Documentation

◆ on_check_function

typedef bool(* sys_var::on_check_function) (sys_var *self, THD *thd, set_var *var)
protected

◆ on_update_function

typedef bool(* sys_var::on_update_function) (sys_var *self, THD *thd, enum_var_type type)
protected

◆ pre_update_function

typedef bool(* sys_var::pre_update_function) (sys_var *self, THD *thd, set_var *var)
protected

Member Enumeration Documentation

◆ binlog_status_enum

Enumeration type to indicate for a system variable whether it will be written to the binlog or not.

Enumerator
VARIABLE_NOT_IN_BINLOG 
SESSION_VARIABLE_IN_BINLOG 

◆ flag_enum

Enumerator
GLOBAL 
SESSION 
ONLY_SESSION 
SCOPE_MASK 
READONLY 
ALLOCATED 
INVISIBLE 
TRI_LEVEL 
NOTPERSIST 
HINT_UPDATEABLE 
PERSIST_AS_READ_ONLY 

There can be some variables which needs to be set before plugin is loaded.

ex: binlog_checksum needs to be set before GR plugin is loaded. Also, there are some variables which needs to be set before some server internal component initialization. ex: binlog_encryption needs to be set before binary and relay log files generation.

SENSITIVE 

Sensitive variable.

If keyring is available, the variable will be persisted in mysqld-auto.cnf in encrypted format

Constructor & Destructor Documentation

◆ sys_var()

sys_var::sys_var ( sys_var_chain chain,
const char *  name_arg,
const char *  comment,
int  flags_arg,
ptrdiff_t  off,
int  getopt_id,
enum get_opt_arg_type  getopt_arg_type,
SHOW_TYPE  show_val_type_arg,
longlong  def_val,
PolyLock lock,
enum binlog_status_enum  binlog_status_arg,
on_check_function  on_check_func,
on_update_function  on_update_func,
const char *  substitute,
int  parse_flag,
sys_var persisted_alias = nullptr,
bool  is_persisted_deprecated = false 
)

sys_var constructor

Parameters
chainvariables are linked into chain for add_static_system_variable_chain() or add_dynamic_system_variable_chain()
name_argthe name of the variable. Must be 0-terminated and exist for the lifetime of the sys_var object.
See also
my_option::name
Parameters
commentshown in mysqld –help,
See also
my_option::comment
Parameters
flags_argor'ed flag_enum values
offoffset of the global variable value from the &global_system_variables.
getopt_id-1 for no command-line option, otherwise
See also
my_option::id
Parameters
getopt_arg_typeno|optional|required value
See also
my_option::arg_type
Parameters
show_val_type_argwhat value_ptr() returns for sql_show.cc
def_valdefault value,
See also
my_option::def_value
Parameters
lockmutex or rw_lock that protects the global variable in addition* to LOCK_global_system_variables.
binlog_status_argif the sysvar will be written to binlog or not
See also
binlog_status_enum
Parameters
on_check_funca function to be called at the end of sys_var::check, put your additional checks here
on_update_funca function to be called at the end of sys_var::update, any post-update activity should happen here
substituteIf non-NULL, this variable is deprecated and the string describes what one should use instead. If an empty string, the variable is deprecated but no replacement is offered.
parse_flageither PARSE_EARLY or PARSE_NORMAL
persisted_aliasIf this variable is persisted, it will appear in the file both under its own name, and using 'persisted_alias'.
is_persisted_deprecatedIf this variable is found in the persisted, variables file, and its alias is not found, a deprecation warning will be issued if is_persisted_deprecated is true. This flag must be false if persisted_alias is null.

◆ ~sys_var()

virtual sys_var::~sys_var ( )
virtualdefault

Member Function Documentation

◆ cast_pluginvar()

virtual sys_var_pluginvar * sys_var::cast_pluginvar ( )
inlinevirtual

downcast for sys_var_pluginvar.

Returns this if it's an instance of sys_var_pluginvar, and 0 otherwise.

Reimplemented in sys_var_pluginvar, and Sys_var_alias.

◆ charset()

const CHARSET_INFO * sys_var::charset ( THD thd)

◆ check()

bool sys_var::check ( THD thd,
set_var var 
)

◆ check_if_sensitive_in_context()

bool sys_var::check_if_sensitive_in_context ( THD thd,
bool  suppress_errors = true 
) const

◆ check_scope()

bool sys_var::check_scope ( enum_var_type  query_type)
inline

Return true for success if: Global query and variable scope is GLOBAL or SESSION, or Session query and variable scope is SESSION or ONLY_SESSION.

◆ check_update_type()

◆ cleanup()

virtual void sys_var::cleanup ( )
inlinevirtual

All the cleanup procedures should be performed here.

Reimplemented in Sys_var_alias, and Sys_var_charptr.

◆ copy_value()

Item * sys_var::copy_value ( THD thd)

Create item from system variable value.

Parameters
thdpointer to THD object
Returns
pointer to Item object or NULL if it's impossible to obtain the value.

◆ do_check()

◆ do_deprecated_warning()

void sys_var::do_deprecated_warning ( THD thd)

◆ get_default()

virtual longlong sys_var::get_default ( )
inlinevirtual

Reimplemented in Sys_var_alias.

◆ get_deprecation_substitute()

const char * sys_var::get_deprecation_substitute ( )
inline

◆ get_host()

virtual const char * sys_var::get_host ( )
inlinevirtual

Reimplemented in Sys_var_alias.

◆ get_max_value()

virtual ulonglong sys_var::get_max_value ( )
inlinevirtual

Reimplemented in sys_var_pluginvar, and Sys_var_alias.

◆ get_min_value()

virtual longlong sys_var::get_min_value ( )
inlinevirtual

Reimplemented in sys_var_pluginvar, and Sys_var_alias.

◆ get_option()

my_option * sys_var::get_option ( )
inline

◆ get_source()

virtual enum_variable_source sys_var::get_source ( )
inlinevirtual

Reimplemented in Sys_var_alias.

◆ get_source_name()

virtual const char * sys_var::get_source_name ( )
inlinevirtual

Reimplemented in Sys_var_alias.

◆ get_timestamp()

virtual ulonglong sys_var::get_timestamp ( ) const
inlinevirtual

Reimplemented in Sys_var_alias.

◆ get_user()

virtual const char * sys_var::get_user ( )
inlinevirtual

Reimplemented in Sys_var_alias.

◆ get_var_type()

virtual ulong sys_var::get_var_type ( )
inlinevirtual

Returns variable type.

Returns
variable type

Reimplemented in Sys_var_alias.

◆ global_save_default()

◆ global_update()

◆ global_value_ptr()

◆ global_var_ptr()

uchar * sys_var::global_var_ptr ( )
protected

◆ is_global_persist()

bool sys_var::is_global_persist ( enum_var_type  type)
inline

◆ is_hint_updateable()

bool sys_var::is_hint_updateable ( ) const
inline

Check if the variable can be set using SET_VAR hint.

Returns
true if the variable can be set using SET_VAR hint, false otherwise.

◆ is_non_persistent()

virtual bool sys_var::is_non_persistent ( )
inlinevirtual

Reimplemented in sys_var_pluginvar, and Sys_var_alias.

◆ is_parse_early()

bool sys_var::is_parse_early ( ) const
inline

◆ is_persist_readonly()

bool sys_var::is_persist_readonly ( ) const
inline

◆ is_readonly()

bool sys_var::is_readonly ( ) const
inline

◆ is_sensitive()

bool sys_var::is_sensitive ( ) const
inline

◆ is_settable_at_command_line()

bool sys_var::is_settable_at_command_line ( )
inline

Return true if settable at the command line.

◆ is_struct()

bool sys_var::is_struct ( )
inline

the following is only true for keycache variables, that support the syntax @keycache_name.variable_name

◆ is_trilevel()

bool sys_var::is_trilevel ( ) const
inline

◆ is_written_to_binlog()

bool sys_var::is_written_to_binlog ( enum_var_type  type)
inline

◆ not_visible()

bool sys_var::not_visible ( ) const
inline

◆ register_option()

bool sys_var::register_option ( std::vector< my_option > *  array,
int  parse_flags 
)
inline

◆ save_default()

void sys_var::save_default ( THD thd,
set_var var 
)
inline

◆ saved_value_to_string()

virtual void sys_var::saved_value_to_string ( THD thd,
set_var var,
char *  def_val 
)
pure virtual

◆ scope()

int sys_var::scope ( ) const
inline

◆ session_save_default()

◆ session_update()

◆ session_value_ptr()

const uchar * sys_var::session_value_ptr ( THD running_thd,
THD target_thd,
std::string_view  keycache_name 
)
protectedvirtual

◆ session_var_ptr()

uchar * sys_var::session_var_ptr ( THD thd)
protected

A pointer to a storage area of the variable, to the raw data.

Typically it's the same as session_value_ptr(), but it's different, for example, for ENUM, that is printed as a string, but stored as a number.

◆ set_and_truncate()

static bool sys_var::set_and_truncate ( char *  dst,
const char *  string,
size_t  sizeof_dst 
)
inlinestaticprivate

Like strncpy, but ensures the destination is '\0'-terminated.

Is also safe to call if dst==string (but not if they overlap in any other way).

Parameters
dstTarget string
stringSource string
sizeof_dstSize of the dst buffer
Return values
falseThe entire string was copied to dst
truestrlen(string) was bigger than or equal to sizeof_dst, so dst contains only the sizeof_dst-1 first characters of string.

◆ set_arg_source()

virtual void sys_var::set_arg_source ( get_opt_arg_source )
inlinevirtual

Reimplemented in Sys_var_alias, and sys_var_pluginvar.

◆ set_default()

bool sys_var::set_default ( THD thd,
set_var var 
)

Update the system variable with the default value from either session or global scope.

The default value is stored in the 'var' argument. Return false when successful.

◆ set_host()

virtual bool sys_var::set_host ( const char *  hst)
inlinevirtual

Reimplemented in Sys_var_alias.

◆ set_is_plugin()

virtual void sys_var::set_is_plugin ( bool  )
inlinevirtual

Reimplemented in Sys_var_alias, and sys_var_pluginvar.

◆ set_source()

virtual void sys_var::set_source ( enum_variable_source  src)
inlinevirtual

Reimplemented in Sys_var_alias.

◆ set_source_name()

virtual bool sys_var::set_source_name ( const char *  path)
inlinevirtual

Reimplemented in Sys_var_alias.

◆ set_timestamp() [1/2]

virtual void sys_var::set_timestamp ( )
inlinevirtual

Reimplemented in Sys_var_alias.

◆ set_timestamp() [2/2]

virtual void sys_var::set_timestamp ( ulonglong  ts)
inlinevirtual

Reimplemented in Sys_var_alias.

◆ set_user()

virtual bool sys_var::set_user ( const char *  usr)
inlinevirtual

Reimplemented in Sys_var_alias.

◆ set_user_host()

void sys_var::set_user_host ( THD thd)
virtual

Reimplemented in Sys_var_alias.

◆ show_type()

SHOW_TYPE sys_var::show_type ( )
inline

◆ update()

bool sys_var::update ( THD thd,
set_var var 
)

◆ update_default()

virtual void sys_var::update_default ( longlong  new_def_value)
inlinevirtual

Reimplemented in Sys_var_alias.

◆ value_ptr() [1/2]

const uchar * sys_var::value_ptr ( THD running_thd,
THD target_thd,
enum_var_type  type,
std::string_view  keycache_name 
)

◆ value_ptr() [2/2]

const uchar * sys_var::value_ptr ( THD thd,
enum_var_type  type,
std::string_view  keycache_name 
)

Friends And Related Function Documentation

◆ Sys_var_alias

friend class Sys_var_alias
friend

Member Data Documentation

◆ binlog_status

enum sys_var::binlog_status_enum sys_var::binlog_status

◆ deprecation_substitute

const char* const sys_var::deprecation_substitute
protected

◆ flags

int sys_var::flags
protected

or'ed flag_enum values

◆ guard

PolyLock* sys_var::guard
protected

second lock that protects the variable

◆ host

char sys_var::host[HOSTNAME_LENGTH+1]
protected

◆ is_os_charset

bool sys_var::is_os_charset
protected

true if the value is in character_set_filesystem

◆ m_is_persisted_deprecated

bool sys_var::m_is_persisted_deprecated

If m_persist_alias is set, and the current variable is deprecated and m_persist_alias is the recommended substitute, then this flag should be set to true.

This has the consequence that the code that loads persisted variables will generate a warning if it encounters this variable but does not encounter the alias.

◆ m_parse_flag

int sys_var::m_parse_flag
protected

either PARSE_EARLY or PARSE_NORMAL.

◆ m_persisted_alias

sys_var* sys_var::m_persisted_alias

If the variable has an alias in the persisted variables file, this should point to it.

This has the following consequences:

  • A SET PERSIST statement that sets either of the variables will persist both variables in the file.
  • When loading persisted variables, an occurrence of any one of the variables will initialize both variables.

◆ name

LEX_CSTRING sys_var::name

◆ next

sys_var* sys_var::next

◆ offset

ptrdiff_t sys_var::offset
protected

offset to the value from global_system_variables

◆ on_check

on_check_function sys_var::on_check
protected

◆ on_update

on_update_function sys_var::on_update
protected

◆ option

my_option sys_var::option
protected

min, max, default values are stored here

◆ PARSE_EARLY

const int sys_var::PARSE_EARLY = 1
static

◆ PARSE_NORMAL

const int sys_var::PARSE_NORMAL = 2
static

◆ pre_update

pre_update_function sys_var::pre_update
protected

Pointer to function to be invoked before updating system variable (but after calling on_check hook), while we do not hold any locks yet.

◆ show_val_type

const SHOW_TYPE sys_var::show_val_type
protected

what value_ptr() returns for sql_show.cc

◆ source

struct get_opt_arg_source sys_var::source
protected

◆ timestamp

ulonglong sys_var::timestamp
protected

◆ user

char sys_var::user[USERNAME_CHAR_LENGTH+1]
protected

The documentation for this class was generated from the following files: