![]() |
MySQL 8.0.43
Source Code Documentation
|
Wrapper interface for all kinds of system variables. More...
#include <set_var.h>
Classes | |
| struct | Cache |
| struct | Component |
| struct | Keycache |
| struct | Plugin |
| struct | Static |
Public Types | |
| enum | Lifetime { STATIC , KEYCACHE , PLUGIN , COMPONENT } |
| typedef Prealloced_array< System_variable_tracker, SYSTEM_VARIABLE_PREALLOC > | Array |
Static Public Member Functions | |
| static System_variable_tracker | make_tracker (std::string_view prefix, std::string_view suffix) |
| Static "constructor". More... | |
| static System_variable_tracker | make_tracker (std::string_view multipart_name) |
| Static "constructor". More... | |
| static bool | enumerate_sys_vars (bool sort, enum enum_var_type type, bool strict, Array *output) |
| Constructs an array of system variables for display to the user. More... | |
Public Attributes | |
| friend | Array |
| sys_var * | m_static_var |
| struct { | |
| sys_var * m_static_var | |
| } | m_static |
| char | m_keycache_var_name [NAME_LEN+sizeof(".key_cache_division_limit")] |
| A dot-separated key cache name or, for a reduced form of key cache variable names, a key cache property name as specified by the caller of System_variable_tracker::make_traker(). More... | |
| size_t | m_keycache_name_size |
| sys_var * | m_keycache_var |
| struct { | |
| char m_keycache_var_name [NAME_LEN+sizeof(".key_cache_division_limit")] | |
| A dot-separated key cache name or, for a reduced form of key cache variable names, a key cache property name as specified by the caller of System_variable_tracker::make_traker(). More... | |
| size_t m_keycache_name_size | |
| sys_var * m_keycache_var | |
| } | m_keycache |
| char | m_plugin_var_name [NAME_LEN+1] |
| A "_"-separated plugin-registered variables name. More... | |
| sys_var * | m_plugin_var_cache |
| struct { | |
| char m_plugin_var_name [NAME_LEN+1] | |
| A "_"-separated plugin-registered variables name. More... | |
| sys_var * m_plugin_var_cache | |
| } | m_plugin |
| char | m_component_var_name [NAME_LEN+sizeof('.')+NAME_LEN+1] |
| A dot-separated component-registered variable name. More... | |
| sys_var * | m_component_var_cache |
| struct { | |
| char m_component_var_name [NAME_LEN+sizeof('.')+NAME_LEN+1] | |
| A dot-separated component-registered variable name. More... | |
| sys_var * m_component_var_cache | |
| } | m_component |
Static Public Attributes | |
| static constexpr size_t | SYSTEM_VARIABLE_PREALLOC = 200 |
| Number of system variable elements to preallocate. More... | |
Private Member Functions | |
| System_variable_tracker (Static, sys_var *var) | |
| System_variable_tracker (Keycache, std::string_view cache_name, sys_var *var) | |
| System_variable_tracker (Plugin, std::string_view name) | |
| System_variable_tracker (Component, std::string_view dot_separated_name) | |
| System_variable_tracker (Component, std::string_view component_name, std::string_view variable_name) | |
| sys_var * | get_stable_var () const |
| bool | visit_plugin_variable (THD *, std::function< bool(sys_var *)>, Suppress_not_found_error, Is_already_locked, Is_single_thread) const |
| bool | visit_component_variable (THD *, std::function< bool(sys_var *)>, Suppress_not_found_error, Is_already_locked, Is_single_thread) const |
| void | cache_metadata (THD *thd, sys_var *v) const |
Static Private Member Functions | |
| static bool | enumerate_sys_vars_in_hash (collation_unordered_map< std::string, sys_var * > *hash, enum enum_var_type query_scope, bool strict, System_variable_tracker::Array *output) |
| static bool | names_are_same (const char *, const char *) |
Private Attributes | |
| Lifetime | m_tag |
| std::optional< Cache > | m_cache |
| union { | |
| struct { | |
| sys_var * m_static_var | |
| } m_static | |
| struct { | |
| char m_keycache_var_name [NAME_LEN+sizeof(".key_cache_division_limit")] | |
| A dot-separated key cache name or, for a reduced form of key cache variable names, a key cache property name as specified by the caller of System_variable_tracker::make_traker(). More... | |
| size_t m_keycache_name_size | |
| sys_var * m_keycache_var | |
| } m_keycache | |
| struct { | |
| char m_plugin_var_name [NAME_LEN+1] | |
| A "_"-separated plugin-registered variables name. More... | |
| sys_var * m_plugin_var_cache | |
| } m_plugin | |
| struct { | |
| char m_component_var_name [NAME_LEN+sizeof('.')+NAME_LEN+1] | |
| A dot-separated component-registered variable name. More... | |
| sys_var * m_component_var_cache | |
| } m_component | |
| }; | |
Static Private Attributes | |
| static thread_local int | m_hash_lock_recursion_depth {0} |
| A non-zero value suppresses LOCK_system_variables_hash guards in System_variable_tracker::access_system_variable. More... | |
Wrapper interface for all kinds of system variables.
The interface encapsulates parse- and execution-time resolvers for all kinds of sys_var: regular (static) system variables MyISAM Multiple Key Cache variables plugin-registered variables component-registered variables Encapsulation of system variable resolving and data accessing tasks.
| typedef Prealloced_array<System_variable_tracker, SYSTEM_VARIABLE_PREALLOC> System_variable_tracker::Array |
|
private |
|
private |
|
private |
|
private |
| System_variable_tracker::System_variable_tracker | ( | const System_variable_tracker & | x | ) |
| System_variable_tracker::~System_variable_tracker | ( | ) |
|
inline |
Safely pass a sys_var object to a function.
Template variant.
access_system_variable() is the most important interface: it does necessary locks, if a dynamic variable is inaccessible then access_system_variable() exits returning empty std::option, otherwise it calls function and returns the result value of function to the caller.
See the pseudo code part at the comment above a signature of the non-template variant of access_system_variable() for details (replace "return true" with "return std::option{}" and "return false" with "return result value of anonymous function call").
| T | A type of a return value of the callback function. |
| thd | A connection handler or nullptr. |
| function | A function to pass a sys_var object if the latest is accessible. |
| suppress_not_found_error | Suppress or output ER_UNKNOWN_SYSTEM_VARIABLE if a dynamic variable is unavailable. |
| force_sensitive_variable_access | Suppress privilege check for SENSITIVE variables. |
| is_already_locked | YES means LOCK_system_variables_hash has already been taken. |
| is_single_thread | YES means we are called from mysqld_main, during bootstrap. |
| bool System_variable_tracker::access_system_variable | ( | THD * | thd, |
| std::function< void(const System_variable_tracker &, sys_var *)> | function = {}, |
||
| Suppress_not_found_error | suppress_not_found_error = Suppress_not_found_error::NO, |
||
| Force_sensitive_system_variable_access | force_sensitive_variable_access = Force_sensitive_system_variable_access::NO, |
||
| Is_already_locked | is_already_locked = Is_already_locked::NO, |
||
| Is_single_thread | is_single_thread = Is_single_thread::NO |
||
| ) | const |
Safely pass a sys_var object to a function. Non-template variant.
access_system_variable() is the most important interface:
it does necessary locks,
if a dynamic variable is inaccessible it exits,
otherwise it calls @p function.
access_system_variable() is reentrant:
being called recursively it suppresses double locks.
Simplified pseudo code of access_system_variable() implementation:
if system variable is @@session_track_system_variables {
a special case: the system variable is static, but it references a comma-separated list of other system variables if function is not no-op { process @session_track_system_variables as plugin-registered one } else { return false // success } } if system variable is static or key cache variable { no dictionary/plugin locks needed call function(cached sys_var pointer) return false // success } if system variable is plugin-registered one { if need to hold LOCK_system_variables_hash { acquire read-only LOCK_system_variables_hash } if need to hold LOCK_plugin { acquire LOCK_plugin, unlock on exit } find sys_var if found { intern_plugin_lock } if this function acquired LOCK_plugin { release LOCK_plugin } if this function acquired LOCK_system_variables_hash { release LOCK_system_variables_hash } if not found or plugin is not in the PLUGIN_IS_READY state { return true // error: variable not found or } call function(found sys_var pointer) return false // success } if system variable is component-registered one { if need to hold LOCK_system_variables_hash(**) { acquire read-only LOCK_system_variables_hash, unlock on exit } find sys_var if not found { return true } call function(found sys_var pointer) return false // success }
| thd | A connection handler or nullptr. |
| function | An optional anonymous function to pass a sys_var object if the latest is accessible. |
| suppress_not_found_error | Suppress or output ER_UNKNOWN_SYSTEM_VARIABLE if a dynamic variable is unavailable. |
| force_sensitive_variable_access | Suppress privilege check for SENSITIVE variables. |
| is_already_locked | YES means LOCK_system_variables_hash has already been taken. |
| is_single_thread | YES means we are called from mysqld_main, during bootstrap. |
|
inline |
|
inline |
|
static |
Constructs an array of system variables for display to the user.
| output | Prealloced_array of elements for display |
| sort | If true, the system variables should be sorted |
| query_scope | OPT_GLOBAL or OPT_SESSION for SHOW GLOBAL|SESSION VARIABLES |
| strict | Use strict scope checking |
|
staticprivate |
|
inline |
|
inline |
|
inlineprivate |
| const char * System_variable_tracker::get_var_name | ( | ) | const |
|
inline |
|
inline |
|
inline |
|
static |
Static "constructor".
| multipart_name | Variable name, optionally dot-separated. |
|
static |
Static "constructor".
| prefix | One of: component name, MyISAM Multiple Key Cache name, or empty string. |
| suffix | In a dot-separated syntax (prefix is mandatory): component-registered variable name, or MyISAM Multiple Key Cache property name. Otherwise (is empty): name of static or plugin-registered variables. |
|
staticprivate |
| void System_variable_tracker::operator= | ( | System_variable_tracker && | x | ) |
|
inline |
|
private |
|
private |
| union { ... } System_variable_tracker::@156 |
|
mutableprivate |
| struct { ... } System_variable_tracker::m_component |
|
mutable |
A dot-separated component-registered variable name.
|
staticprivate |
A non-zero value suppresses LOCK_system_variables_hash guards in System_variable_tracker::access_system_variable.
| struct { ... } System_variable_tracker::m_keycache |
| size_t System_variable_tracker::m_keycache_name_size |
| sys_var* System_variable_tracker::m_keycache_var |
| char System_variable_tracker::m_keycache_var_name[NAME_LEN+sizeof(".key_cache_division_limit")] |
A dot-separated key cache name or, for a reduced form of key cache variable names, a key cache property name as specified by the caller of System_variable_tracker::make_traker().
| struct { ... } System_variable_tracker::m_plugin |
|
mutable |
| char System_variable_tracker::m_plugin_var_name[NAME_LEN+1] |
A "_"-separated plugin-registered variables name.
| struct { ... } System_variable_tracker::m_static |
| sys_var* System_variable_tracker::m_static_var |
|
private |
|
staticconstexpr |
Number of system variable elements to preallocate.