143
165
and persist it in the provided pointer to the dynamic variable.
144
166
For example, strings may require memory to be allocated.
146
typedef void (*var_update_func)(Session *session,
168
typedef void (*mysql_var_update_func)(Session *session,
147
169
drizzle_sys_var *var,
148
170
void *var_ptr, const void *save);
173
/* the following declarations are for internal use only */
176
#define PLUGIN_VAR_MASK \
177
(PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | \
178
PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_NOCMDARG | \
179
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC)
181
#define DRIZZLE_PLUGIN_VAR_HEADER \
184
const char *comment; \
185
mysql_var_check_func check; \
186
mysql_var_update_func update
188
#define DRIZZLE_SYSVAR_NAME(name) drizzle_sysvar_ ## name
189
#define DRIZZLE_SYSVAR(name) \
190
((drizzle_sys_var *)(&(DRIZZLE_SYSVAR_NAME(name))))
193
for global variables, the value pointer is the first
194
element after the header, the default value is the second.
195
for thread variables, the value offset is the first
196
element after the header, the default value is the second.
200
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
201
DRIZZLE_PLUGIN_VAR_HEADER; \
203
const type def_val; \
204
} DRIZZLE_SYSVAR_NAME(name)
206
#define DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, type) struct { \
207
DRIZZLE_PLUGIN_VAR_HEADER; \
208
type *value; type def_val; \
209
type min_val; type max_val; \
211
} DRIZZLE_SYSVAR_NAME(name)
213
#define DECLARE_SessionVAR_FUNC(type) \
214
type *(*resolve)(Session *session, int offset)
216
#define DECLARE_DRIZZLE_SessionVAR_BASIC(name, type) struct { \
217
DRIZZLE_PLUGIN_VAR_HEADER; \
219
const type def_val; \
220
DECLARE_SessionVAR_FUNC(type); \
221
} DRIZZLE_SYSVAR_NAME(name)
223
#define DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, type) struct { \
224
DRIZZLE_PLUGIN_VAR_HEADER; \
226
type def_val; type min_val; \
227
type max_val; type blk_sz; \
228
DECLARE_SessionVAR_FUNC(type); \
229
} DRIZZLE_SYSVAR_NAME(name)
231
#define DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, type) struct { \
232
DRIZZLE_PLUGIN_VAR_HEADER; \
235
DECLARE_SessionVAR_FUNC(type); \
237
} DRIZZLE_SYSVAR_NAME(name)
241
the following declarations are for use by plugin implementors
244
#define DRIZZLE_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
245
DECLARE_DRIZZLE_SYSVAR_BASIC(name, bool) = { \
246
PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \
247
#name, comment, check, update, &varname, def}
249
#define DRIZZLE_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
250
DECLARE_DRIZZLE_SYSVAR_BASIC(name, char *) = { \
251
PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
252
#name, comment, check, update, &varname, def}
254
#define DRIZZLE_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
255
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int) = { \
256
PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \
257
#name, comment, check, update, &varname, def, min, max, blk }
259
#define DRIZZLE_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \
260
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned int) = { \
261
PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
262
#name, comment, check, update, &varname, def, min, max, blk }
264
#define DRIZZLE_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \
265
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, long) = { \
266
PLUGIN_VAR_LONG | ((opt) & PLUGIN_VAR_MASK), \
267
#name, comment, check, update, &varname, def, min, max, blk }
269
#define DRIZZLE_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \
270
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned long) = { \
271
PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
272
#name, comment, check, update, &varname, def, min, max, blk }
274
#define DRIZZLE_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
275
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int64_t) = { \
276
PLUGIN_VAR_LONGLONG | ((opt) & PLUGIN_VAR_MASK), \
277
#name, comment, check, update, &varname, def, min, max, blk }
279
#define DRIZZLE_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
280
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, uint64_t) = { \
281
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
282
#name, comment, check, update, &varname, def, min, max, blk }
284
#define DRIZZLE_SessionVAR_BOOL(name, opt, comment, check, update, def) \
285
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char) = { \
286
PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
287
#name, comment, check, update, -1, def, NULL}
289
#define DRIZZLE_SessionVAR_STR(name, opt, comment, check, update, def) \
290
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char *) = { \
291
PLUGIN_VAR_STR | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
292
#name, comment, check, update, -1, def, NULL}
294
#define DRIZZLE_SessionVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
295
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int) = { \
296
PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
297
#name, comment, check, update, -1, def, min, max, blk, NULL }
299
#define DRIZZLE_SessionVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
300
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned int) = { \
301
PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
302
#name, comment, check, update, -1, def, min, max, blk, NULL }
304
#define DRIZZLE_SessionVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
305
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, long) = { \
306
PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
307
#name, comment, check, update, -1, def, min, max, blk, NULL }
309
#define DRIZZLE_SessionVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
310
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned long) = { \
311
PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
312
#name, comment, check, update, -1, def, min, max, blk, NULL }
314
#define DRIZZLE_SessionVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
315
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int64_t) = { \
316
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
317
#name, comment, check, update, -1, def, min, max, blk, NULL }
319
#define DRIZZLE_SessionVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
320
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, uint64_t) = { \
321
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
322
#name, comment, check, update, -1, def, min, max, blk, NULL }
324
/* accessor macros */
326
#define SYSVAR(name) \
327
(*(DRIZZLE_SYSVAR_NAME(name).value))
329
/* when session == null, result points to global value */
330
#define SessionVAR(session, name) \
331
(*(DRIZZLE_SYSVAR_NAME(name).resolve(session, DRIZZLE_SYSVAR_NAME(name).offset)))
334
/*************************************************************************
335
drizzle_value struct for reading values from mysqld.
336
Used by server variables framework to parse user-provided values.
337
Will be used for arguments when implementing UDFs.
339
Note that val_str() returns a string in temporary memory
340
that will be freed at the end of statement. Copy the string
341
if you need it to persist.
344
#define DRIZZLE_VALUE_TYPE_STRING 0
345
#define DRIZZLE_VALUE_TYPE_REAL 1
346
#define DRIZZLE_VALUE_TYPE_INT 2
153
349
skeleton of a plugin variable - portion of structure common to all.
155
351
struct drizzle_sys_var
353
DRIZZLE_PLUGIN_VAR_HEADER;
159
356
void plugin_opt_set_limits(option *options, const drizzle_sys_var *opt);