143
140
and persist it in the provided pointer to the dynamic variable.
144
141
For example, strings may require memory to be allocated.
146
typedef void (*var_update_func)(Session *session,
143
typedef void (*mysql_var_update_func)(Session *session,
147
144
drizzle_sys_var *var,
148
145
void *var_ptr, const void *save);
148
/* the following declarations are for internal use only */
151
#define PLUGIN_VAR_MASK \
152
(PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | \
153
PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_NOCMDARG | \
154
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC)
156
#define DRIZZLE_PLUGIN_VAR_HEADER \
159
const char *comment; \
160
mysql_var_check_func check; \
161
mysql_var_update_func update
163
#define DRIZZLE_SYSVAR_NAME(name) drizzle_sysvar_ ## name
164
#define DRIZZLE_SYSVAR(name) \
165
((drizzle_sys_var *)(&(DRIZZLE_SYSVAR_NAME(name))))
168
for global variables, the value pointer is the first
169
element after the header, the default value is the second.
170
for thread variables, the value offset is the first
171
element after the header, the default value is the second.
175
#define DECLARE_DRIZZLE_SYSVAR_BOOL(name) struct { \
176
DRIZZLE_PLUGIN_VAR_HEADER; \
179
} DRIZZLE_SYSVAR_NAME(name)
181
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
182
DRIZZLE_PLUGIN_VAR_HEADER; \
184
const type def_val; \
185
} DRIZZLE_SYSVAR_NAME(name)
187
#define DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, type) struct { \
188
DRIZZLE_PLUGIN_VAR_HEADER; \
189
type *value; type def_val; \
190
type min_val; type max_val; \
192
} DRIZZLE_SYSVAR_NAME(name)
194
#define DECLARE_SessionVAR_FUNC(type) \
195
type *(*resolve)(Session *session, int offset)
197
#define DECLARE_DRIZZLE_SessionVAR_BASIC(name, type) struct { \
198
DRIZZLE_PLUGIN_VAR_HEADER; \
200
const type def_val; \
201
DECLARE_SessionVAR_FUNC(type); \
202
} DRIZZLE_SYSVAR_NAME(name)
204
#define DECLARE_DRIZZLE_SessionVAR_BOOL(name) struct { \
205
DRIZZLE_PLUGIN_VAR_HEADER; \
208
DECLARE_SessionVAR_FUNC(bool); \
209
} DRIZZLE_SYSVAR_NAME(name)
211
#define DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, type) struct { \
212
DRIZZLE_PLUGIN_VAR_HEADER; \
214
type def_val; type min_val; \
215
type max_val; type blk_sz; \
216
DECLARE_SessionVAR_FUNC(type); \
217
} DRIZZLE_SYSVAR_NAME(name)
219
#define DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, type) struct { \
220
DRIZZLE_PLUGIN_VAR_HEADER; \
223
DECLARE_SessionVAR_FUNC(type); \
225
} DRIZZLE_SYSVAR_NAME(name)
229
the following declarations are for use by plugin implementors
232
#define DECLARE_DRIZZLE_SYSVAR_BOOL(name) struct { \
233
DRIZZLE_PLUGIN_VAR_HEADER; \
236
} DRIZZLE_SYSVAR_NAME(name)
239
#define DRIZZLE_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
240
DECLARE_DRIZZLE_SYSVAR_BOOL(name) = { \
241
PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \
242
#name, comment, check, update, &varname, def}
244
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
245
DRIZZLE_PLUGIN_VAR_HEADER; \
247
const type def_val; \
248
} DRIZZLE_SYSVAR_NAME(name)
250
#define DRIZZLE_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
251
DECLARE_DRIZZLE_SYSVAR_BASIC(name, char *) = { \
252
PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
253
#name, comment, check, update, &varname, def}
255
#define DRIZZLE_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
256
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int) = { \
257
PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \
258
#name, comment, check, update, &varname, def, min, max, blk }
260
#define DRIZZLE_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \
261
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned int) = { \
262
PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
263
#name, comment, check, update, &varname, def, min, max, blk }
265
#define DRIZZLE_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \
266
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, long) = { \
267
PLUGIN_VAR_LONG | ((opt) & PLUGIN_VAR_MASK), \
268
#name, comment, check, update, &varname, def, min, max, blk }
270
#define DRIZZLE_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \
271
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned long) = { \
272
PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
273
#name, comment, check, update, &varname, def, min, max, blk }
275
#define DRIZZLE_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
276
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int64_t) = { \
277
PLUGIN_VAR_LONGLONG | ((opt) & PLUGIN_VAR_MASK), \
278
#name, comment, check, update, &varname, def, min, max, blk }
280
#define DRIZZLE_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
281
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, uint64_t) = { \
282
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
283
#name, comment, check, update, &varname, def, min, max, blk }
285
#define DRIZZLE_SessionVAR_BOOL(name, opt, comment, check, update, def) \
286
DECLARE_DRIZZLE_SessionVAR_BOOL(name) = { \
287
PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
288
#name, comment, check, update, -1, def, NULL}
290
#define DRIZZLE_SessionVAR_STR(name, opt, comment, check, update, def) \
291
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char *) = { \
292
PLUGIN_VAR_STR | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
293
#name, comment, check, update, -1, def, NULL}
295
#define DRIZZLE_SessionVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
296
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int) = { \
297
PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
298
#name, comment, check, update, -1, def, min, max, blk, NULL }
300
#define DRIZZLE_SessionVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
301
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned int) = { \
302
PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
303
#name, comment, check, update, -1, def, min, max, blk, NULL }
305
#define DRIZZLE_SessionVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
306
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, long) = { \
307
PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
308
#name, comment, check, update, -1, def, min, max, blk, NULL }
310
#define DRIZZLE_SessionVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
311
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned long) = { \
312
PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
313
#name, comment, check, update, -1, def, min, max, blk, NULL }
315
#define DRIZZLE_SessionVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
316
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int64_t) = { \
317
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
318
#name, comment, check, update, -1, def, min, max, blk, NULL }
320
#define DRIZZLE_SessionVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
321
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, uint64_t) = { \
322
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
323
#name, comment, check, update, -1, def, min, max, blk, NULL }
325
/* accessor macros */
327
#define SYSVAR(name) \
328
(*(DRIZZLE_SYSVAR_NAME(name).value))
330
/* when session == null, result points to global value */
331
#define SessionVAR(session, name) \
332
(*(DRIZZLE_SYSVAR_NAME(name).resolve(session, DRIZZLE_SYSVAR_NAME(name).offset)))
335
/*************************************************************************
336
drizzle_value struct for reading values from mysqld.
337
Used by server variables framework to parse user-provided values.
338
Will be used for arguments when implementing UDFs.
340
Note that val_str() returns a string in temporary memory
341
that will be freed at the end of statement. Copy the string
342
if you need it to persist.
345
#define DRIZZLE_VALUE_TYPE_STRING 0
346
#define DRIZZLE_VALUE_TYPE_REAL 1
347
#define DRIZZLE_VALUE_TYPE_INT 2
153
350
skeleton of a plugin variable - portion of structure common to all.
155
352
struct drizzle_sys_var
354
DRIZZLE_PLUGIN_VAR_HEADER;
159
357
void plugin_opt_set_limits(option *options, const drizzle_sys_var *opt);