MySQL 9.0.0
Source Code Documentation
component_sys_var_service_imp.h
Go to the documentation of this file.
1/* Copyright (c) 2017, 2024, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License, version 2.0,
5as published by the Free Software Foundation.
6
7This program is designed to work with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have either included with
13the program or referenced in the documentation.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License, version 2.0, for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef COMPONENT_SYSTEM_VAR_SERVICE_H
25#define COMPONENT_SYSTEM_VAR_SERVICE_H
26
29
31
32#define COPY_MYSQL_PLUGIN_VAR_HEADER(sys_var_type, type, sys_var_check, \
33 sys_var_update) \
34 sys_var_type->flags = flags; \
35 sys_var_type->name = var_name; \
36 sys_var_type->comment = comment; \
37 sys_var_type->check = check_func ? check_func : sys_var_check; \
38 sys_var_type->update = update_func ? update_func : sys_var_update; \
39 sys_var_type->value = (type *)variable_value;
40
41#define COPY_MYSQL_PLUGIN_THDVAR_HEADER(sys_var_type, type, sys_var_check, \
42 sys_var_update) \
43 sys_var_type->flags = flags; \
44 sys_var_type->name = var_name; \
45 sys_var_type->comment = comment; \
46 sys_var_type->check = check_func ? check_func : sys_var_check; \
47 sys_var_type->update = update_func ? update_func : sys_var_update; \
48 sys_var_type->offset = -1;
49
50#define COPY_MYSQL_PLUGIN_VAR_REMAINING(sys_var_type, check_arg_type) \
51 sys_var_type->def_val = check_arg_type->def_val; \
52 sys_var_type->min_val = check_arg_type->min_val; \
53 sys_var_type->max_val = check_arg_type->max_val; \
54 sys_var_type->blk_sz = check_arg_type->blk_sz;
55
56#define THDVAR_FUNC(type) type *(*resolve)(MYSQL_THD thd, int offset)
57
58#define SYSVAR_INTEGRAL_TYPE(type) \
59 struct sysvar_##type##_type { \
60 MYSQL_PLUGIN_VAR_HEADER; \
61 type *value; \
62 type def_val; \
63 type min_val; \
64 type max_val; \
65 type blk_sz; \
66 }
67
68#define THDVAR_INTEGRAL_TYPE(type) \
69 struct thdvar_##type##_type { \
70 MYSQL_PLUGIN_VAR_HEADER; \
71 int offset; \
72 type def_val; \
73 type min_val; \
74 type max_val; \
75 type blk_sz; \
76 THDVAR_FUNC(type); \
77 }
78
79#define SYSVAR_ENUM_TYPE(type) \
80 struct sysvar_##type##_type { \
81 MYSQL_PLUGIN_VAR_HEADER; \
82 unsigned long *value; \
83 unsigned long def_val; \
84 TYPE_LIB *typelib; \
85 }
86
87#define THDVAR_ENUM_TYPE(type) \
88 struct thdvar_##type##_type { \
89 MYSQL_PLUGIN_VAR_HEADER; \
90 int offset; \
91 unsigned long def_val; \
92 THDVAR_FUNC(unsigned long); \
93 TYPE_LIB *typelib; \
94 }
95
96#define SYSVAR_BOOL_TYPE(type) \
97 struct sysvar_##type##_type { \
98 MYSQL_PLUGIN_VAR_HEADER; \
99 bool *value; \
100 bool def_val; \
101 }
102
103#define THDVAR_BOOL_TYPE(type) \
104 struct thdvar_##type##_type { \
105 MYSQL_PLUGIN_VAR_HEADER; \
106 int offset; \
107 bool def_val; \
108 THDVAR_FUNC(type); \
109 }
110
111#define SYSVAR_STR_TYPE(type) \
112 struct sysvar_##type##_type { \
113 MYSQL_PLUGIN_VAR_HEADER; \
114 char **value; \
115 char *def_val; \
116 }
117
118#define THDVAR_STR_TYPE(type) \
119 struct thdvar_##type##_type { \
120 MYSQL_PLUGIN_VAR_HEADER; \
121 int offset; \
122 char *def_val; \
123 THDVAR_FUNC(char *); \
124 }
125
126/**
127 An implementation of the configuration system variables Service to register
128 variable and unregister variable.
129*/
131 public:
132 /**
133 Register's component system variables.
134
135 @param component_name name of the component
136 @param var_name variable name
137 @param flags tells about the variable type
138 @param comment variable comment message
139 @param check_func function pointer, which is called at variable check time
140 @param update_func function pointer, which is called at update time
141 @param check_arg type defined check constraints block
142 @param variable_value place holder for variable value
143 @return Status of performed operation
144 @retval false success
145 @retval true failure
146 */
148 (const char *component_name, const char *var_name,
149 int flags, const char *comment,
150 mysql_sys_var_check_func check_func,
151 mysql_sys_var_update_func update_func,
152 void *check_arg, void *variable_value));
153
154 /**
155 Get the component system variable value from the global structure.
156
157 @param component_name Name of the component
158 @param var_name Name of the variable
159 @param[in,out] val On input: a buffer to hold the value. On output a pointer
160 to the value.
161 @param[in,out] out_length_of_val On input: size of longest string that the
162 buffer can contain. On output the length of the copied string.
163 @return Status of performed operation
164 @retval false success
165 @retval true failure
166 */
168 (const char *component_name, const char *var_name,
169 void **val, size_t *out_length_of_val));
170
171 /**
172 Unregister's component system variable.
173
174 @param component_name name of the component
175 @param var_name Variable name
176 @return Status of performed operation
177 @retval false success
178 @retval true failure
179 */
181 (const char *component_name, const char *var_name));
182};
183#endif /* COMPONENT_SYSTEM_VAR_SERVICE_H */
An implementation of the configuration system variables Service to register variable and unregister v...
Definition: component_sys_var_service_imp.h:130
static mysql_service_status_t get_variable(const char *component_name, const char *var_name, void **val, size_t *out_length_of_val) noexcept
Get the component system variable value from the global structure.
Definition: component_sys_var_service.cc:699
static mysql_service_status_t unregister_variable(const char *component_name, const char *var_name) noexcept
Unregister's component system variable.
Definition: component_sys_var_service.cc:721
static mysql_service_status_t register_variable(const char *component_name, const char *var_name, int flags, const char *comment, mysql_sys_var_check_func check_func, mysql_sys_var_update_func update_func, void *check_arg, void *variable_value) noexcept
Register's component system variables.
Definition: component_sys_var_service.cc:125
int(* mysql_sys_var_check_func)(MYSQL_THD thd, SYS_VAR *var, void *save, struct st_mysql_value *value)
Signature for the check function.
Definition: component_sys_var_service.h:78
void(* mysql_sys_var_update_func)(MYSQL_THD thd, SYS_VAR *var, void *val_ptr, const void *save)
Signature for the update function.
Definition: component_sys_var_service.h:106
void mysql_comp_sys_var_services_init()
Definition: component_sys_var_service.cc:95
static int flags[50]
Definition: hp_test1.cc:40
#define comment
Definition: lexyy.cc:959
Specifies macros to define Service Implementations.
#define DEFINE_BOOL_METHOD(name, args)
A short macro to define method that returns bool, which is the most common case.
Definition: service_implementation.h:88