MySQL 8.0.30
Source Code Documentation
persisted_variable.cc File Reference
#include "sql/persisted_variable.h"
#include "my_config.h"
#include <assert.h>
#include <ctype.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <algorithm>
#include <iomanip>
#include <memory>
#include <new>
#include <utility>
#include "mysql/components/library_mysys/my_hex_tools.h"
#include "keyring_operations_helper.h"
#include "lex_string.h"
#include "m_ctype.h"
#include "m_string.h"
#include "my_aes.h"
#include "my_compiler.h"
#include "my_default.h"
#include "my_getopt.h"
#include "my_io.h"
#include "my_loglevel.h"
#include "my_macros.h"
#include "my_rnd.h"
#include "my_sys.h"
#include "my_thread.h"
#include "mysql/components/services/bits/psi_bits.h"
#include "mysql/components/services/bits/psi_file_bits.h"
#include "mysql/components/services/bits/psi_memory_bits.h"
#include "mysql/components/services/bits/psi_mutex_bits.h"
#include "mysql/components/services/log_builtins.h"
#include "mysql/components/services/log_shared.h"
#include "mysql/components/services/system_variable_source_type.h"
#include "mysql/psi/mysql_file.h"
#include "mysql/psi/mysql_memory.h"
#include "mysql/psi/mysql_mutex.h"
#include "mysql/status_var.h"
#include "mysql_version.h"
#include "mysqld_error.h"
#include "prealloced_array.h"
#include "scope_guard.h"
#include "sql-common/json_dom.h"
#include "sql/auth/auth_acls.h"
#include "sql/auth/auth_internal.h"
#include "sql/auth/sql_security_ctx.h"
#include "sql/current_thd.h"
#include "sql/debug_sync.h"
#include "sql/derror.h"
#include "sql/item.h"
#include "sql/log.h"
#include "sql/mysqld.h"
#include "sql/server_component/mysql_server_keyring_lockable_imp.h"
#include "sql/set_var.h"
#include "sql/sql_class.h"
#include "sql/sql_error.h"
#include "sql/sql_lex.h"
#include "sql/sql_list.h"
#include "sql/sql_show.h"
#include "sql/sys_vars_shared.h"
#include "sql/thr_malloc.h"
#include "sql_string.h"
#include "template_utils.h"
#include "thr_mutex.h"
#include "typelib.h"

Classes

struct  sort_tv_by_timestamp
 A comparison operator to sort persistent variables entries by timestamp. More...
 

Namespaces

namespace  anonymous_namespace{persisted_variable.cc}
 

Functions

void my_init_persist_psi_keys (void)
 CLASS Persisted_variables_cache Holds <name,value> pair of all options which needs to be persisted to a file. More...
 
std::string anonymous_namespace{persisted_variable.cc}::tolower_varname (const char *name)
 
static bool check_boolean_value (const char *value, String &bool_str)
 For boolean variable types do validation on what value is set for the variable and then report error in case an invalid value is set. More...
 
static bool format_json (const st_persist_var &entry, Json_object &section_object)
 
static bool add_json_object (Json_object &section_object, Json_object &json_object, const char *key_section)
 
static bool format_set (Persisted_variables_uset &section, string key_section, Json_object &json_object)
 
static bool format_map (Persisted_variables_umap &section, string key_section, Json_object &json_object)
 
static bool extract_variable_value_and_metadata (const Json_object *json_object, st_persist_var &output)
 
static bool extract_set (const Json_object &json_object, const std::string set_key, Persisted_variables_uset &output)
 
static bool extract_map (const Json_object &json_object, const std::string map_key, Persisted_variables_umap &output)
 
static bool extract_string (Json_object *obj, const std::string &key, std::string &value)
 

Variables

constexpr char anonymous_namespace{persisted_variable.cc}::s_key_value [] = "Value"
 
constexpr char anonymous_namespace{persisted_variable.cc}::s_key_metadata [] = "Metadata"
 
constexpr char anonymous_namespace{persisted_variable.cc}::s_key_timestamp [] = "Timestamp"
 
constexpr char anonymous_namespace{persisted_variable.cc}::s_key_user [] = "User"
 
constexpr char anonymous_namespace{persisted_variable.cc}::s_key_host [] = "Host"
 
constexpr char anonymous_namespace{persisted_variable.cc}::s_key_mysql_dynamic_parse_early_variables []
 
constexpr char anonymous_namespace{persisted_variable.cc}::s_key_mysql_sensitive_dynamic_variables []
 
constexpr char anonymous_namespace{persisted_variable.cc}::s_key_mysql_dynamic_variables [] = "mysql_dynamic_variables"
 
constexpr char anonymous_namespace{persisted_variable.cc}::s_key_mysql_static_parse_early_variables []
 
constexpr char anonymous_namespace{persisted_variable.cc}::s_key_mysql_sensitive_static_variables []
 
constexpr char anonymous_namespace{persisted_variable.cc}::s_key_mysql_static_variables [] = "mysql_static_variables"
 
constexpr char anonymous_namespace{persisted_variable.cc}::s_key_mysql_sensitive_variables [] = "mysql_sensitive_variables"
 
constexpr char anonymous_namespace{persisted_variable.cc}::s_key_master_key_id [] = "master_key_id"
 
constexpr char anonymous_namespace{persisted_variable.cc}::s_key_file_key [] = "file_key"
 
constexpr char anonymous_namespace{persisted_variable.cc}::s_key_file_key_iv [] = "file_key_iv"
 
constexpr char anonymous_namespace{persisted_variable.cc}::s_key_key_encryption_algorithm [] = "key_encryption_algorithm"
 
constexpr char anonymous_namespace{persisted_variable.cc}::s_key_data_encryption_algorithm [] = "data_encryption_algorithm"
 
constexpr char anonymous_namespace{persisted_variable.cc}::s_key_mysql_sensitive_variables_iv []
 
constexpr char anonymous_namespace{persisted_variable.cc}::s_key_mysql_sensitive_variables_blob []
 
constexpr char anonymous_namespace{persisted_variable.cc}::s_key_mysql_encryption_algorithm_default [] = "AES_256_CBC"
 
PSI_file_key key_persist_file_cnf
 
static PSI_file_info all_persist_files []
 
PSI_mutex_key key_persist_file
 
PSI_mutex_key key_persist_variables
 
static PSI_mutex_info all_persist_mutexes []
 
PSI_memory_key key_memory_persisted_variables
 
static PSI_memory_info all_options []
 

Function Documentation

◆ add_json_object()

static bool add_json_object ( Json_object section_object,
Json_object json_object,
const char *  key_section 
)
static

◆ check_boolean_value()

static bool check_boolean_value ( const char *  value,
String bool_str 
)
static

For boolean variable types do validation on what value is set for the variable and then report error in case an invalid value is set.

Parameters
[in]valueValue which needs to be checked for.
[out]bool_strTarget String into which correct value needs to be stored after validation.
Returns
true Failure if value is set to anything other than "true", "on", "1", "false" , "off", "0"
false Success

◆ extract_map()

static bool extract_map ( const Json_object json_object,
const std::string  map_key,
Persisted_variables_umap output 
)
static

◆ extract_set()

static bool extract_set ( const Json_object json_object,
const std::string  set_key,
Persisted_variables_uset output 
)
static

◆ extract_string()

static bool extract_string ( Json_object obj,
const std::string &  key,
std::string &  value 
)
static

◆ extract_variable_value_and_metadata()

static bool extract_variable_value_and_metadata ( const Json_object json_object,
st_persist_var output 
)
static

◆ format_json()

static bool format_json ( const st_persist_var entry,
Json_object section_object 
)
static

◆ format_map()

static bool format_map ( Persisted_variables_umap section,
string  key_section,
Json_object json_object 
)
static

◆ format_set()

static bool format_set ( Persisted_variables_uset section,
string  key_section,
Json_object json_object 
)
static

◆ my_init_persist_psi_keys()

void my_init_persist_psi_keys ( void  )

CLASS Persisted_variables_cache Holds <name,value> pair of all options which needs to be persisted to a file.

OVERVIEW

When first SET PERSIST statement is executed we instantiate Persisted_variables_cache which loads the config file if present into m_persisted_dynamic_variables set. This is a singleton operation. m_persisted_dynamic_variables is an in-memory copy of config file itself. If the SET statement passes then this in-memory is updated and flushed to file as an atomic operation.

Next SET PERSIST statement would only update the in-memory copy and sync to config file instead of loading the file again.

Variable Documentation

◆ all_options

PSI_memory_info all_options[]
static
Initial value:
= {
{&key_memory_persisted_variables, "persisted_options_root", 0,
#define PSI_DOCUMENT_ME
Definition: component_common.h:28
#define PSI_FLAG_ONLY_GLOBAL_STAT
Global stat only flag.
Definition: psi_bits.h:111
PSI_memory_key key_memory_persisted_variables
Definition: persisted_variable.cc:149

◆ all_persist_files

PSI_file_info all_persist_files[]
static
Initial value:
= {
PSI_file_key key_persist_file_cnf
Definition: persisted_variable.cc:133

◆ all_persist_mutexes

PSI_mutex_info all_persist_mutexes[]
static
Initial value:
= {
{&key_persist_file, "m_LOCK_persist_file", 0, 0, PSI_DOCUMENT_ME},
{&key_persist_variables, "m_LOCK_persist_variables", 0, 0,
PSI_mutex_key key_persist_file
Definition: persisted_variable.cc:140
PSI_mutex_key key_persist_variables
Definition: persisted_variable.cc:140

◆ key_memory_persisted_variables

PSI_memory_key key_memory_persisted_variables

◆ key_persist_file

PSI_mutex_key key_persist_file

◆ key_persist_file_cnf

PSI_file_key key_persist_file_cnf

◆ key_persist_variables

PSI_mutex_key key_persist_variables