MySQL 8.0.40
Source Code Documentation
sql_plugin_var.h File Reference
#include <string.h>
#include <sys/types.h>
#include <new>
#include <string>
#include "lex_string.h"
#include "map_helpers.h"
#include "memory_debugging.h"
#include "my_compiler.h"
#include "my_getopt.h"
#include "my_inttypes.h"
#include "my_sys.h"
#include "mysql/components/services/bits/psi_bits.h"
#include "mysql/plugin.h"
#include "mysql/service_mysql_alloc.h"
#include "mysql/udf_registration_types.h"
#include "sql/set_var.h"

Go to the source code of this file.

Classes

struct  st_bookmark
 
struct  SYS_VAR
 
class  sys_var_pluginvar
 
struct  st_item_value_holder
 

Macros

#define OPTION_SET_LIMITS(type, options, opt)
 
#define OPTION_SET_LIMITS_DOUBLE(options, opt)
 
#define MYSQL_SYSVAR_NAME(name)   name
 
#define PLUGIN_VAR_TYPEMASK   0x007f
 
#define PLUGIN_VAR_WITH_SIGN_TYPEMASK   0x00ff
 
#define EXTRA_OPTIONS   3 /* options for: 'foo', 'plugin-foo' and NULL */
 

Functions

typedef DECLARE_MYSQL_SYSVAR_BASIC (sysvar_bool_t, bool)
 
typedef DECLARE_MYSQL_THDVAR_BASIC (thdvar_bool_t, bool)
 
typedef DECLARE_MYSQL_SYSVAR_BASIC (sysvar_str_t, char *)
 
typedef DECLARE_MYSQL_THDVAR_BASIC (thdvar_str_t, char *)
 
typedef DECLARE_MYSQL_SYSVAR_TYPELIB (sysvar_enum_t, unsigned long)
 
typedef DECLARE_MYSQL_THDVAR_TYPELIB (thdvar_enum_t, unsigned long)
 
typedef DECLARE_MYSQL_SYSVAR_TYPELIB (sysvar_set_t, ulonglong)
 
typedef DECLARE_MYSQL_THDVAR_TYPELIB (thdvar_set_t, ulonglong)
 
typedef DECLARE_MYSQL_SYSVAR_SIMPLE (sysvar_int_t, int)
 
typedef DECLARE_MYSQL_SYSVAR_SIMPLE (sysvar_long_t, long)
 
typedef DECLARE_MYSQL_SYSVAR_SIMPLE (sysvar_longlong_t, longlong)
 
typedef DECLARE_MYSQL_SYSVAR_SIMPLE (sysvar_uint_t, uint)
 
typedef DECLARE_MYSQL_SYSVAR_SIMPLE (sysvar_ulong_t, ulong)
 
typedef DECLARE_MYSQL_SYSVAR_SIMPLE (sysvar_ulonglong_t, ulonglong)
 
typedef DECLARE_MYSQL_SYSVAR_SIMPLE (sysvar_double_t, double)
 
typedef DECLARE_MYSQL_THDVAR_SIMPLE (thdvar_int_t, int)
 
typedef DECLARE_MYSQL_THDVAR_SIMPLE (thdvar_long_t, long)
 
typedef DECLARE_MYSQL_THDVAR_SIMPLE (thdvar_longlong_t, longlong)
 
typedef DECLARE_MYSQL_THDVAR_SIMPLE (thdvar_uint_t, uint)
 
typedef DECLARE_MYSQL_THDVAR_SIMPLE (thdvar_ulong_t, ulong)
 
typedef DECLARE_MYSQL_THDVAR_SIMPLE (thdvar_ulonglong_t, ulonglong)
 
typedef DECLARE_MYSQL_THDVAR_SIMPLE (thdvar_double_t, double)
 
int check_func_bool (THD *, SYS_VAR *, void *save, st_mysql_value *value)
 
int check_func_int (THD *thd, SYS_VAR *var, void *save, st_mysql_value *value)
 
int check_func_long (THD *thd, SYS_VAR *var, void *save, st_mysql_value *value)
 
int check_func_longlong (THD *thd, SYS_VAR *var, void *save, st_mysql_value *value)
 
int check_func_str (THD *thd, SYS_VAR *, void *save, st_mysql_value *value)
 
int check_func_enum (THD *, SYS_VAR *var, void *save, st_mysql_value *value)
 
int check_func_set (THD *, SYS_VAR *var, void *save, st_mysql_value *value)
 
int check_func_double (THD *thd, SYS_VAR *var, void *save, st_mysql_value *value)
 
void update_func_bool (THD *, SYS_VAR *, void *tgt, const void *save)
 
void update_func_int (THD *, SYS_VAR *, void *tgt, const void *save)
 
void update_func_long (THD *, SYS_VAR *, void *tgt, const void *save)
 
void update_func_longlong (THD *, SYS_VAR *, void *tgt, const void *save)
 
void update_func_str (THD *, SYS_VAR *, void *tgt, const void *save)
 
void update_func_double (THD *, SYS_VAR *, void *tgt, const void *save)
 
SHOW_TYPE pluginvar_show_type (SYS_VAR *plugin_var)
 
int item_value_type (st_mysql_value *value)
 
const char * item_val_str (st_mysql_value *value, char *buffer, int *length)
 
int item_val_int (st_mysql_value *value, long long *buf)
 
int item_is_unsigned (st_mysql_value *value)
 
int item_val_real (st_mysql_value *value, double *buf)
 
void plugin_opt_set_limits (struct my_option *, const SYS_VAR *)
 
ucharintern_sys_var_ptr (THD *thd, int offset, bool global_lock)
 
bool plugin_var_memalloc_global_update (THD *thd, SYS_VAR *var, char **dest, const char *value)
 Set value for global variable with PLUGIN_VAR_MEMALLOC flag. More...
 
bool plugin_var_memalloc_session_update (THD *thd, SYS_VAR *var, char **dest, const char *value)
 Set value for thread local variable with PLUGIN_VAR_MEMALLOC flag. More...
 
st_bookmarkfind_bookmark (const char *plugin, const char *name, int flags)
 
void convert_underscore_to_dash (char *str, size_t len)
 
malloc_unordered_map< std::string, st_bookmark * > * get_bookmark_hash ()
 

Macro Definition Documentation

◆ EXTRA_OPTIONS

#define EXTRA_OPTIONS   3 /* options for: 'foo', 'plugin-foo' and NULL */

◆ MYSQL_SYSVAR_NAME

#define MYSQL_SYSVAR_NAME (   name)    name

◆ OPTION_SET_LIMITS

#define OPTION_SET_LIMITS (   type,
  options,
  opt 
)
Value:
options->var_type = type; \
options->def_value = (opt)->def_val; \
options->min_value = (opt)->min_val; \
options->max_value = (opt)->max_val; \
options->block_size = (long)(opt)->blk_sz
Definition: options.cc:49
required string type
Definition: replication_group_member_actions.proto:34

◆ OPTION_SET_LIMITS_DOUBLE

#define OPTION_SET_LIMITS_DOUBLE (   options,
  opt 
)
Value:
options->var_type = GET_DOUBLE; \
options->def_value = (longlong)getopt_double2ulonglong((opt)->def_val); \
options->min_value = (longlong)getopt_double2ulonglong((opt)->min_val); \
options->max_value = getopt_double2ulonglong((opt)->max_val); \
options->block_size = (long)(opt)->blk_sz;
#define GET_DOUBLE
Definition: my_getopt.h:57
long long int longlong
Definition: my_inttypes.h:55
ulonglong getopt_double2ulonglong(double v)
Returns an ulonglong value containing a raw representation of the given double value.
Definition: my_getopt.cc:157

◆ PLUGIN_VAR_TYPEMASK

#define PLUGIN_VAR_TYPEMASK   0x007f

◆ PLUGIN_VAR_WITH_SIGN_TYPEMASK

#define PLUGIN_VAR_WITH_SIGN_TYPEMASK   0x00ff

Function Documentation

◆ check_func_bool()

int check_func_bool ( THD ,
SYS_VAR ,
void *  save,
st_mysql_value value 
)

◆ check_func_double()

int check_func_double ( THD thd,
SYS_VAR var,
void *  save,
st_mysql_value value 
)

◆ check_func_enum()

int check_func_enum ( THD ,
SYS_VAR var,
void *  save,
st_mysql_value value 
)

◆ check_func_int()

int check_func_int ( THD thd,
SYS_VAR var,
void *  save,
st_mysql_value value 
)

◆ check_func_long()

int check_func_long ( THD thd,
SYS_VAR var,
void *  save,
st_mysql_value value 
)

◆ check_func_longlong()

int check_func_longlong ( THD thd,
SYS_VAR var,
void *  save,
st_mysql_value value 
)

◆ check_func_set()

int check_func_set ( THD ,
SYS_VAR var,
void *  save,
st_mysql_value value 
)

◆ check_func_str()

int check_func_str ( THD thd,
SYS_VAR ,
void *  save,
st_mysql_value value 
)

◆ convert_underscore_to_dash()

void convert_underscore_to_dash ( char *  str,
size_t  len 
)
inline

◆ DECLARE_MYSQL_SYSVAR_BASIC() [1/2]

typedef DECLARE_MYSQL_SYSVAR_BASIC ( sysvar_bool_t  ,
bool   
)

◆ DECLARE_MYSQL_SYSVAR_BASIC() [2/2]

typedef DECLARE_MYSQL_SYSVAR_BASIC ( sysvar_str_t  ,
char *   
)

◆ DECLARE_MYSQL_SYSVAR_SIMPLE() [1/7]

typedef DECLARE_MYSQL_SYSVAR_SIMPLE ( sysvar_double_t  ,
double   
)

◆ DECLARE_MYSQL_SYSVAR_SIMPLE() [2/7]

typedef DECLARE_MYSQL_SYSVAR_SIMPLE ( sysvar_int_t  ,
int   
)

◆ DECLARE_MYSQL_SYSVAR_SIMPLE() [3/7]

typedef DECLARE_MYSQL_SYSVAR_SIMPLE ( sysvar_long_t  ,
long   
)

◆ DECLARE_MYSQL_SYSVAR_SIMPLE() [4/7]

typedef DECLARE_MYSQL_SYSVAR_SIMPLE ( sysvar_longlong_t  ,
longlong   
)

◆ DECLARE_MYSQL_SYSVAR_SIMPLE() [5/7]

typedef DECLARE_MYSQL_SYSVAR_SIMPLE ( sysvar_uint_t  ,
uint   
)

◆ DECLARE_MYSQL_SYSVAR_SIMPLE() [6/7]

typedef DECLARE_MYSQL_SYSVAR_SIMPLE ( sysvar_ulong_t  ,
ulong   
)

◆ DECLARE_MYSQL_SYSVAR_SIMPLE() [7/7]

typedef DECLARE_MYSQL_SYSVAR_SIMPLE ( sysvar_ulonglong_t  ,
ulonglong   
)

◆ DECLARE_MYSQL_SYSVAR_TYPELIB() [1/2]

typedef DECLARE_MYSQL_SYSVAR_TYPELIB ( sysvar_enum_t  ,
unsigned long   
)

◆ DECLARE_MYSQL_SYSVAR_TYPELIB() [2/2]

typedef DECLARE_MYSQL_SYSVAR_TYPELIB ( sysvar_set_t  ,
ulonglong   
)

◆ DECLARE_MYSQL_THDVAR_BASIC() [1/2]

typedef DECLARE_MYSQL_THDVAR_BASIC ( thdvar_bool_t  ,
bool   
)

◆ DECLARE_MYSQL_THDVAR_BASIC() [2/2]

typedef DECLARE_MYSQL_THDVAR_BASIC ( thdvar_str_t  ,
char *   
)

◆ DECLARE_MYSQL_THDVAR_SIMPLE() [1/7]

typedef DECLARE_MYSQL_THDVAR_SIMPLE ( thdvar_double_t  ,
double   
)

◆ DECLARE_MYSQL_THDVAR_SIMPLE() [2/7]

typedef DECLARE_MYSQL_THDVAR_SIMPLE ( thdvar_int_t  ,
int   
)

◆ DECLARE_MYSQL_THDVAR_SIMPLE() [3/7]

typedef DECLARE_MYSQL_THDVAR_SIMPLE ( thdvar_long_t  ,
long   
)

◆ DECLARE_MYSQL_THDVAR_SIMPLE() [4/7]

typedef DECLARE_MYSQL_THDVAR_SIMPLE ( thdvar_longlong_t  ,
longlong   
)

◆ DECLARE_MYSQL_THDVAR_SIMPLE() [5/7]

typedef DECLARE_MYSQL_THDVAR_SIMPLE ( thdvar_uint_t  ,
uint   
)

◆ DECLARE_MYSQL_THDVAR_SIMPLE() [6/7]

typedef DECLARE_MYSQL_THDVAR_SIMPLE ( thdvar_ulong_t  ,
ulong   
)

◆ DECLARE_MYSQL_THDVAR_SIMPLE() [7/7]

typedef DECLARE_MYSQL_THDVAR_SIMPLE ( thdvar_ulonglong_t  ,
ulonglong   
)

◆ DECLARE_MYSQL_THDVAR_TYPELIB() [1/2]

typedef DECLARE_MYSQL_THDVAR_TYPELIB ( thdvar_enum_t  ,
unsigned long   
)

◆ DECLARE_MYSQL_THDVAR_TYPELIB() [2/2]

typedef DECLARE_MYSQL_THDVAR_TYPELIB ( thdvar_set_t  ,
ulonglong   
)

◆ find_bookmark()

st_bookmark * find_bookmark ( const char *  plugin,
const char *  name,
int  flags 
)

◆ get_bookmark_hash()

malloc_unordered_map< std::string, st_bookmark * > * get_bookmark_hash ( )

◆ intern_sys_var_ptr()

uchar * intern_sys_var_ptr ( THD thd,
int  offset,
bool  global_lock 
)

◆ item_is_unsigned()

int item_is_unsigned ( st_mysql_value value)

◆ item_val_int()

int item_val_int ( st_mysql_value value,
long long *  buf 
)

◆ item_val_real()

int item_val_real ( st_mysql_value value,
double *  buf 
)

◆ item_val_str()

const char * item_val_str ( st_mysql_value value,
char *  buffer,
int *  length 
)

◆ item_value_type()

int item_value_type ( st_mysql_value value)

◆ plugin_opt_set_limits()

void plugin_opt_set_limits ( struct my_option options,
const SYS_VAR opt 
)

◆ plugin_var_memalloc_global_update()

bool plugin_var_memalloc_global_update ( THD thd,
SYS_VAR var,
char **  dest,
const char *  value 
)

Set value for global variable with PLUGIN_VAR_MEMALLOC flag.

Parameters
[in]thdThread context.
[in]varPlugin variable.
[in,out]destDestination memory pointer.
[in]value'\0'-terminated new value.
Returns
Completion status
Return values
falseSuccess
trueFailure

◆ plugin_var_memalloc_session_update()

bool plugin_var_memalloc_session_update ( THD thd,
SYS_VAR var,
char **  dest,
const char *  value 
)

Set value for thread local variable with PLUGIN_VAR_MEMALLOC flag.

Parameters
[in]thdThread context.
[in]varPlugin variable.
[in,out]destDestination memory pointer.
[in]value'\0'-terminated new value.

Most plugin variable values are stored on dynamic_variables_ptr. Releasing memory occupied by these values is as simple as freeing dynamic_variables_ptr.

An exception to the rule are PLUGIN_VAR_MEMALLOC variables, which are stored on individual memory hunks. All of these hunks has to be freed when it comes to cleanup.

It may happen that a plugin was uninstalled and descriptors of it's variables are lost. In this case it is impossible to locate corresponding values.

In addition to allocating and setting variable value, new element is added to dynamic_variables_allocs list. When thread is done, it has to call plugin_var_memalloc_free() to release memory used by PLUGIN_VAR_MEMALLOC variables.

If var is NULL, variable update function is not called. This is needed when we take snapshot of system variables during thread initialization.

Note
List element and variable value are stored on the same memory hunk. List element is followed by variable value.
Returns
Completion status
Return values
falseSuccess
trueFailure

◆ pluginvar_show_type()

SHOW_TYPE pluginvar_show_type ( SYS_VAR plugin_var)

◆ update_func_bool()

void update_func_bool ( THD ,
SYS_VAR ,
void *  tgt,
const void *  save 
)

◆ update_func_double()

void update_func_double ( THD ,
SYS_VAR ,
void *  tgt,
const void *  save 
)

◆ update_func_int()

void update_func_int ( THD ,
SYS_VAR ,
void *  tgt,
const void *  save 
)

◆ update_func_long()

void update_func_long ( THD ,
SYS_VAR ,
void *  tgt,
const void *  save 
)

◆ update_func_longlong()

void update_func_longlong ( THD ,
SYS_VAR ,
void *  tgt,
const void *  save 
)

◆ update_func_str()

void update_func_str ( THD ,
SYS_VAR ,
void *  tgt,
const void *  save 
)