MySQL 8.4.2
Source Code Documentation
component_sys_var_service.h File Reference

Go to the source code of this file.

Classes

struct  TYPE_LIB
 A utility class for the ENUM variables. More...
 
struct  s_mysql_component_sys_variable_register
 Service to register variable and get variable value. More...
 
struct  s_mysql_component_sys_variable_unregister
 Service to unregister variable. More...
 

Macros

#define MYSQL_THD   THD *
 
#define COPY_MYSQL_PLUGIN_VAR_HEADER(sys_var_type, type, sys_var_check, sys_var_update)
 
#define COPY_MYSQL_PLUGIN_VAR_REMAINING(sys_var_type, check_arg_type)
 
#define SYSVAR_INTEGRAL_TYPE(type)
 
#define SYSVAR_ENUM_TYPE(type)
 
#define SYSVAR_BOOL_TYPE(type)
 
#define SYSVAR_STR_TYPE(type)
 
#define INTEGRAL_CHECK_ARG(type)
 Defines an integral placeholder to fill in with values and pass to the registration function. More...
 
#define ENUM_CHECK_ARG(type)
 Defines an TYPE_LIB placeholder to fill in with values and pass to the registration function. More...
 
#define BOOL_CHECK_ARG(type)
 Defines a bool placeholder to fill in with values and pass to the registration function. More...
 
#define STR_CHECK_ARG(type)
 Defines a char * placeholder to fill in with values and pass to the registration function. More...
 

Typedefs

typedef int(* mysql_sys_var_check_func) (MYSQL_THD thd, SYS_VAR *var, void *save, struct st_mysql_value *value)
 Signature for the check function. More...
 
typedef void(* mysql_sys_var_update_func) (MYSQL_THD thd, SYS_VAR *var, void *val_ptr, const void *save)
 Signature for the update function. More...
 
typedef struct s_mysql_component_sys_variable_register mysql_service_component_sys_variable_register_t
 Service to register variable and get variable value. More...
 
typedef struct s_mysql_component_sys_variable_unregister mysql_service_component_sys_variable_unregister_t
 Service to unregister variable. More...
 

Macro Definition Documentation

◆ COPY_MYSQL_PLUGIN_VAR_HEADER

#define COPY_MYSQL_PLUGIN_VAR_HEADER (   sys_var_type,
  type,
  sys_var_check,
  sys_var_update 
)
Value:
sys_var_type->flags = flags; \
sys_var_type->name = var_name; \
sys_var_type->comment = comment; \
sys_var_type->check = check_func ? check_func : sys_var_check; \
sys_var_type->update = update_func ? update_func : sys_var_update; \
sys_var_type->value = (type *)variable_value;
static int flags[50]
Definition: hp_test1.cc:40
#define comment
Definition: lexyy.cc:959
required string type
Definition: replication_group_member_actions.proto:34

◆ COPY_MYSQL_PLUGIN_VAR_REMAINING

#define COPY_MYSQL_PLUGIN_VAR_REMAINING (   sys_var_type,
  check_arg_type 
)
Value:
sys_var_type->def_val = check_arg_type->def_val; \
sys_var_type->min_val = check_arg_type->min_val; \
sys_var_type->max_val = check_arg_type->max_val; \
sys_var_type->blk_sz = check_arg_type->blk_sz;

◆ MYSQL_THD

#define MYSQL_THD   THD *

◆ SYSVAR_BOOL_TYPE

#define SYSVAR_BOOL_TYPE (   type)
Value:
struct sysvar_##type##_type { \
MYSQL_PLUGIN_VAR_HEADER; \
bool *value; \
bool def_val; \
}

◆ SYSVAR_ENUM_TYPE

#define SYSVAR_ENUM_TYPE (   type)
Value:
struct sysvar_##type##_type { \
MYSQL_PLUGIN_VAR_HEADER; \
unsigned long *value; \
unsigned long def_val; \
TYPE_LIB *typelib; \
}

◆ SYSVAR_INTEGRAL_TYPE

#define SYSVAR_INTEGRAL_TYPE (   type)
Value:
struct sysvar_##type##_type { \
MYSQL_PLUGIN_VAR_HEADER; \
type *value; \
type def_val; \
type min_val; \
type max_val; \
type blk_sz; \
}

◆ SYSVAR_STR_TYPE

#define SYSVAR_STR_TYPE (   type)
Value:
struct sysvar_##type##_type { \
MYSQL_PLUGIN_VAR_HEADER; \
char **value; \
char *def_val; \
}

Typedef Documentation

◆ mysql_sys_var_check_func

typedef int(* mysql_sys_var_check_func) (MYSQL_THD thd, SYS_VAR *var, void *save, struct st_mysql_value *value)

Signature for the check function.

This is called to check if the value supplied is valid and can be set as a new variable value at that time. It needs to extract the value supplied from the value API pointer. Note that extracting this value can be expensive (e.g. a scalar subquery) hence it should be done only once. This is why the result of this should be stored into the save output parameter so that it can be further reused by update() etc. For a multi-variable SET statement the server will first call all of the check functions and only if they all return success it will start calling the update functions. So the idea is that the update function should succeed no matter what. And all the necessary checks should be done in the check function. If you do not supply a check or update function the server will use the basic ones to check e.g. min and max values for the integer types etc.

Parameters
thdThe thread handle to the current thread
varhandle to the system variable definition
[out]saveplaceholder for the value. This should be cast according to the type
valueInterface to extract the actual parameter value.
Returns
status
Return values
0success
1failure
See also
mysql_sys_var_update_func, mysql_service_component_sys_variable_register_t

◆ mysql_sys_var_update_func

typedef void(* mysql_sys_var_update_func) (MYSQL_THD thd, SYS_VAR *var, void *val_ptr, const void *save)

Signature for the update function.

This is called to set the updated value into the var_ptr placeholder and invoke any side effects that may stem from setting this system variable.

It receives the pre-calculated value (usually from mysql_sys_var_check_func) in the save pointer. It needs to set it into the var_ptr pointer and invoke any side effects.

For a multi-variable SET statement the server will first call all of the check functions and only if they all return success it will start calling the update functions. So the idea is that the update function should succeed no matter what. And all the necessary checks should be done in the check function. If you do not supply an update function the server will use the basic one to set the value according to the variable's type.

Parameters
thdThe thread handle to the current thread
varhandle to the system variable definition
[out]val_ptrplaceholder for the value. Store save in here.
saveThe pre-calculated value from check.
See also
mysql_sys_var_check_func, mysql_service_component_sys_variable_register_t