MySQL  8.0.17
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:
Sys_var_charptr Sys_var_charptr_func Sys_var_dbug Sys_var_double Sys_var_gtid_next Sys_var_gtid_purged Sys_var_have Sys_var_integer< T, ARGT, SHOWT, SIGNED > Sys_var_multi_enum Sys_var_plugin sys_var_pluginvar Sys_var_proxy_user Sys_var_struct< Struct_type, Name_getter > Sys_var_typelib Sys_var_tz

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
}
 
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 constructor More...
 
virtual ~sys_var ()
 
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, LEX_STRING *base)
 
const ucharvalue_ptr (THD *thd, enum_var_type type, LEX_STRING *base)
 
virtual void update_default (longlong new_def_value)
 
longlong get_default ()
 
virtual bool is_default (THD *thd, set_var *var)
 
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)
 
enum_variable_source get_source ()
 
const char * get_source_name ()
 
void set_source (enum_variable_source src)
 
bool set_source_name (const char *path)
 
bool set_user (const char *usr)
 
const char * get_user ()
 
const char * get_host ()
 
bool set_host (const char *hst)
 
ulonglong get_timestamp () const
 
void set_user_host (THD *thd)
 
my_optionget_option ()
 
void set_timestamp ()
 
void set_timestamp (ulonglong ts)
 
void clear_user_host_timestamp ()
 
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_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)
 

Public Attributes

sys_varnext
 
LEX_CSTRING name
 
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(* 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, LEX_STRING *base)
 A pointer to a value of the variable for SHOW. More...
 
virtual const ucharglobal_value_ptr (THD *thd, LEX_STRING *base)
 
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
 
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)
 

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

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.

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 constructor

Parameters
chainvariables are linked into chain for mysql_add_sys_var_chain()
name_argthe name of the variable. Must be 0-terminated and exist for the liftime 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_type
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_arg
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

◆ ~sys_var()

virtual sys_var::~sys_var ( )
inlinevirtual

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.

◆ charset()

const CHARSET_INFO * sys_var::charset ( THD thd)

◆ check()

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

◆ 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_charptr.

◆ clear_user_host_timestamp()

void sys_var::clear_user_host_timestamp ( )
inline

◆ 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()

longlong sys_var::get_default ( )
inline

◆ get_host()

const char* sys_var::get_host ( )
inline

◆ get_max_value()

virtual ulonglong sys_var::get_max_value ( )
inlinevirtual

Reimplemented in sys_var_pluginvar.

◆ get_min_value()

virtual longlong sys_var::get_min_value ( )
inlinevirtual

Reimplemented in sys_var_pluginvar.

◆ get_option()

my_option* sys_var::get_option ( )
inline

◆ get_source()

enum_variable_source sys_var::get_source ( )
inline

◆ get_source_name()

const char* sys_var::get_source_name ( )
inline

◆ get_timestamp()

ulonglong sys_var::get_timestamp ( ) const
inline

◆ get_user()

const char* sys_var::get_user ( )
inline

◆ get_var_type()

virtual ulong sys_var::get_var_type ( )
inlinevirtual

Returns variable type.

Returns
variable type

◆ global_save_default()

◆ global_update()

◆ global_value_ptr()

◆ global_var_ptr()

uchar * sys_var::global_var_ptr ( )
protected

◆ is_default()

bool sys_var::is_default ( THD thd,
set_var var 
)
virtual

Reimplemented in sys_var_pluginvar.

◆ 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.

◆ is_persist_readonly()

bool sys_var::is_persist_readonly ( ) const
inline

◆ is_readonly()

bool sys_var::is_readonly ( ) 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,
LEX_STRING base 
)
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

◆ set_arg_source()

virtual void sys_var::set_arg_source ( get_opt_arg_source )
inlinevirtual

Reimplemented in 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()

bool sys_var::set_host ( const char *  hst)
inline

◆ set_is_plugin()

virtual void sys_var::set_is_plugin ( bool  )
inlinevirtual

Reimplemented in sys_var_pluginvar.

◆ set_source()

void sys_var::set_source ( enum_variable_source  src)
inline

◆ set_source_name()

bool sys_var::set_source_name ( const char *  path)
inline

◆ set_timestamp() [1/2]

void sys_var::set_timestamp ( )
inline

◆ set_timestamp() [2/2]

void sys_var::set_timestamp ( ulonglong  ts)
inline

◆ set_user()

bool sys_var::set_user ( const char *  usr)
inline

◆ set_user_host()

void sys_var::set_user_host ( THD thd)

◆ 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

◆ value_ptr() [1/2]

const uchar * sys_var::value_ptr ( THD running_thd,
THD target_thd,
enum_var_type  type,
LEX_STRING base 
)

◆ value_ptr() [2/2]

const uchar * sys_var::value_ptr ( THD thd,
enum_var_type  type,
LEX_STRING base 
)

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_parse_flag

int sys_var::m_parse_flag
protected

either PARSE_EARLY or PARSE_NORMAL.

◆ 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

◆ 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: