MySQL  8.0.19
Source Code Documentation
component_sys_var_service.h File Reference
#include <stddef.h>
#include <mysql/components/service.h>

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
 
struct  s_mysql_component_sys_variable_unregister
 

Macros

#define PLUGIN_VAR_BOOL   0x0001
 bool variable. More...
 
#define PLUGIN_VAR_INT   0x0002
 int variable. More...
 
#define PLUGIN_VAR_LONG   0x0003
 long variable Use INTEGRAL_CHECK_ARG More...
 
#define PLUGIN_VAR_LONGLONG   0x0004
 longlong variable. More...
 
#define PLUGIN_VAR_STR   0x0005
 char * variable. More...
 
#define PLUGIN_VAR_ENUM   0x0006
 Enum variable. More...
 
#define PLUGIN_VAR_SET   0x0007
 A set variable. More...
 
#define PLUGIN_VAR_DOUBLE   0x0008
 double variable. More...
 
#define PLUGIN_VAR_UNSIGNED   0x0080
 The variable is unsigned. More...
 
#define PLUGIN_VAR_THDLOCAL   0x0100
 Variable is per-connection. More...
 
#define PLUGIN_VAR_READONLY   0x0200
 Server variable is read only. More...
 
#define PLUGIN_VAR_NOSYSVAR   0x0400
 Not a server variable. More...
 
#define PLUGIN_VAR_NOCMDOPT   0x0800
 Not a command line option. More...
 
#define PLUGIN_VAR_NOCMDARG   0x1000
 No argument for cmd line. More...
 
#define PLUGIN_VAR_RQCMDARG   0x0000
 Argument required for cmd line. More...
 
#define PLUGIN_VAR_OPCMDARG   0x2000
 Argument optional for cmd line. More...
 
#define PLUGIN_VAR_NODEFAULT   0x4000
 SET DEFAULT is prohibited. More...
 
#define PLUGIN_VAR_MEMALLOC   0x8000
 String needs memory allocated. More...
 
#define PLUGIN_VAR_NOPERSIST   0x10000
 SET PERSIST_ONLY is prohibited for read only variables. More...
 
#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 *var_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
 
typedef struct s_mysql_component_sys_variable_unregister mysql_service_component_sys_variable_unregister_t
 

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;

◆ 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 futher 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 *var_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
value
const string value("\"Value\"")
comment
#define comment
Definition: lexyy.cc:959
HttpMethod::type
int type
Definition: http_common.h:411
flags
static int flags[50]
Definition: hp_test1.cc:39