MySQL 8.4.2
Source Code Documentation
|
Service to register variable and get variable value. More...
#include <component_sys_var_service.h>
Public Attributes | |
mysql_service_status_t(* | register_variable )(const char *component_name, const char *name, int flags, const char *comment, mysql_sys_var_check_func check, mysql_sys_var_update_func update, void *check_arg, void *variable_value) |
Register a new system variable. More... | |
mysql_service_status_t(* | get_variable )(const char *component_name, const char *name, void **val, size_t *out_length_of_val) |
Fetches the global value of a system variable. More... | |
Service to register variable and get variable value.
mysql_service_status_t(* s_mysql_component_sys_variable_register::get_variable) (const char *component_name, const char *name, void **val, size_t *out_length_of_val) |
Fetches the global value of a system variable.
Call this to get the global value of a variable. You can access both the component variables (SELECT @global.component_name.variable_name) and the "legacy" system variables (SELECT @global.variable_name) that are registered by the server component. To access the latter you need to pass "mysql_server" (lowercase) as a component name.
A pointer to the value is returned into the val input/output argument. And the length of the value (as applicable) is returned into the out_length_of_val argument.
In case when the user buffer was too small to copy the value, the call fails and needed buffer size is returned by 'out_length_of_val'.
Typical use (char * variable):
component_name | Name of the component or "mysql_server" for the legacy ones. | |
name | name of the variable | |
[in,out] | val | On input: a buffer to hold the value. On output a pointer to the value. |
[in,out] | out_length_of_val | On input: the buffer size. On output the length of the data copied. |
true | failure |
false | success |
mysql_service_status_t(* s_mysql_component_sys_variable_register::register_variable) (const char *component_name, const char *name, int flags, const char *comment, mysql_sys_var_check_func check, mysql_sys_var_update_func update, void *check_arg, void *variable_value) |
Register a new system variable.
The variable registered is then accessible in SQL as "SELECT component_name.name" The variable registration needs a global of the relevant type that stores the value.
To define a new variable you need to:
Typical use
component_name | The name of the component the system variable belongs to. |
name | The name of the variable. |
flags | one of Variable types plus zero or more of group_components_services_sys_var_service_flags |
comment | explanation of what the variable is to be shown in metadata tables |
check | A function to be called to check for validity of the new value. |
update | A function to be called when the variable value is updated |
check_arg | The variable declared through one of Variable |
variable_value | A pointer to a storage location of the relevant type. |
true | operation failed |
false | operation succeeded |