MySQL 9.1.0
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 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

◆ MYSQL_THD

#define MYSQL_THD   THD *

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