MySQL 9.1.0
Source Code Documentation
|
Fetches the session/global/persist value of a system variable. More...
#include <mysql_system_variable.h>
Public Attributes | |
mysql_service_status_t(* | get )(THD *hthd, const char *variable_type, const char *component_name, const char *variable_name, void **val, size_t *out_length_of_val) |
Gets the value of a system variable. More... | |
Fetches the session/global/persist value of a system variable.
This is an example of using the service:
Call this to get the session/global/persist value of a variable. You can access both the component variables (SELECT ["@@"][scope "."]component_name "." variable_name; where scope ::= SESSION | LOCAL | GLOBAL) and the "legacy" system variables (SELECT ["@@"][scope "."].variable_name; where scope ::= SESSION | LOCAL | GLOBAL) 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'.
Decide on a variable storage type among one of "GLOBAL" or "SESSION"
Typical use (char * variable):
mysql_service_status_t(* s_mysql_mysql_system_variable_reader::get) (THD *hthd, const char *variable_type, const char *component_name, const char *variable_name, void **val, size_t *out_length_of_val) |
Gets the value of a system variable.
hthd | thread session handle. if NULL, the GLOBAL value of the variable is returned. | |
variable_type | one of [GLOBAL, SESSION]. | |
component_name | Name of the component or "mysql_server" for the legacy ones. | |
variable_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 |