143
168
and persist it in the provided pointer to the dynamic variable.
144
169
For example, strings may require memory to be allocated.
146
typedef void (*var_update_func)(Session *session,
171
typedef void (*mysql_var_update_func)(Session *session,
147
172
drizzle_sys_var *var,
148
173
void *var_ptr, const void *save);
176
/* the following declarations are for internal use only */
179
#define PLUGIN_VAR_MASK \
180
(PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | \
181
PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_NOCMDARG | \
182
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC)
184
#define DRIZZLE_PLUGIN_VAR_HEADER \
187
const char *comment; \
188
mysql_var_check_func check; \
189
mysql_var_update_func update
191
#define DRIZZLE_SYSVAR_NAME(name) mysql_sysvar_ ## name
192
#define DRIZZLE_SYSVAR(name) \
193
((drizzle_sys_var *)(&(DRIZZLE_SYSVAR_NAME(name))))
196
for global variables, the value pointer is the first
197
element after the header, the default value is the second.
198
for thread variables, the value offset is the first
199
element after the header, the default value is the second.
203
#define DECLARE_DRIZZLE_SYSVAR_BASIC(name, type) struct { \
204
DRIZZLE_PLUGIN_VAR_HEADER; \
206
const type def_val; \
207
} DRIZZLE_SYSVAR_NAME(name)
209
#define DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, type) struct { \
210
DRIZZLE_PLUGIN_VAR_HEADER; \
211
type *value; type def_val; \
212
type min_val; type max_val; \
214
} DRIZZLE_SYSVAR_NAME(name)
216
#define DECLARE_SessionVAR_FUNC(type) \
217
type *(*resolve)(Session *session, int offset)
219
#define DECLARE_DRIZZLE_SessionVAR_BASIC(name, type) struct { \
220
DRIZZLE_PLUGIN_VAR_HEADER; \
222
const type def_val; \
223
DECLARE_SessionVAR_FUNC(type); \
224
} DRIZZLE_SYSVAR_NAME(name)
226
#define DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, type) struct { \
227
DRIZZLE_PLUGIN_VAR_HEADER; \
229
type def_val; type min_val; \
230
type max_val; type blk_sz; \
231
DECLARE_SessionVAR_FUNC(type); \
232
} DRIZZLE_SYSVAR_NAME(name)
234
#define DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, type) struct { \
235
DRIZZLE_PLUGIN_VAR_HEADER; \
238
DECLARE_SessionVAR_FUNC(type); \
240
} DRIZZLE_SYSVAR_NAME(name)
244
the following declarations are for use by plugin implementors
247
#define DRIZZLE_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
248
DECLARE_DRIZZLE_SYSVAR_BASIC(name, bool) = { \
249
PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \
250
#name, comment, check, update, &varname, def}
252
#define DRIZZLE_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
253
DECLARE_DRIZZLE_SYSVAR_BASIC(name, char *) = { \
254
PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
255
#name, comment, check, update, &varname, def}
257
#define DRIZZLE_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
258
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int) = { \
259
PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \
260
#name, comment, check, update, &varname, def, min, max, blk }
262
#define DRIZZLE_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \
263
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned int) = { \
264
PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
265
#name, comment, check, update, &varname, def, min, max, blk }
267
#define DRIZZLE_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \
268
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, long) = { \
269
PLUGIN_VAR_LONG | ((opt) & PLUGIN_VAR_MASK), \
270
#name, comment, check, update, &varname, def, min, max, blk }
272
#define DRIZZLE_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \
273
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, unsigned long) = { \
274
PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
275
#name, comment, check, update, &varname, def, min, max, blk }
277
#define DRIZZLE_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
278
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, int64_t) = { \
279
PLUGIN_VAR_LONGLONG | ((opt) & PLUGIN_VAR_MASK), \
280
#name, comment, check, update, &varname, def, min, max, blk }
282
#define DRIZZLE_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
283
DECLARE_DRIZZLE_SYSVAR_SIMPLE(name, uint64_t) = { \
284
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
285
#name, comment, check, update, &varname, def, min, max, blk }
287
#define DRIZZLE_SessionVAR_BOOL(name, opt, comment, check, update, def) \
288
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char) = { \
289
PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
290
#name, comment, check, update, -1, def, NULL}
292
#define DRIZZLE_SessionVAR_STR(name, opt, comment, check, update, def) \
293
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char *) = { \
294
PLUGIN_VAR_STR | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
295
#name, comment, check, update, -1, def, NULL}
297
#define DRIZZLE_SessionVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
298
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int) = { \
299
PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
300
#name, comment, check, update, -1, def, min, max, blk, NULL }
302
#define DRIZZLE_SessionVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
303
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned int) = { \
304
PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
305
#name, comment, check, update, -1, def, min, max, blk, NULL }
307
#define DRIZZLE_SessionVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
308
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, long) = { \
309
PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
310
#name, comment, check, update, -1, def, min, max, blk, NULL }
312
#define DRIZZLE_SessionVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
313
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned long) = { \
314
PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
315
#name, comment, check, update, -1, def, min, max, blk, NULL }
317
#define DRIZZLE_SessionVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
318
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int64_t) = { \
319
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
320
#name, comment, check, update, -1, def, min, max, blk, NULL }
322
#define DRIZZLE_SessionVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
323
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, uint64_t) = { \
324
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
325
#name, comment, check, update, -1, def, min, max, blk, NULL }
327
/* accessor macros */
329
#define SYSVAR(name) \
330
(*(DRIZZLE_SYSVAR_NAME(name).value))
332
/* when session == null, result points to global value */
333
#define SessionVAR(session, name) \
334
(*(DRIZZLE_SYSVAR_NAME(name).resolve(session, DRIZZLE_SYSVAR_NAME(name).offset)))
337
/*************************************************************************
338
drizzle_value struct for reading values from mysqld.
339
Used by server variables framework to parse user-provided values.
340
Will be used for arguments when implementing UDFs.
342
Note that val_str() returns a string in temporary memory
343
that will be freed at the end of statement. Copy the string
344
if you need it to persist.
347
#define DRIZZLE_VALUE_TYPE_STRING 0
348
#define DRIZZLE_VALUE_TYPE_REAL 1
349
#define DRIZZLE_VALUE_TYPE_INT 2
153
352
skeleton of a plugin variable - portion of structure common to all.
155
354
struct drizzle_sys_var
356
DRIZZLE_PLUGIN_VAR_HEADER;
159
359
void plugin_opt_set_limits(option *options, const drizzle_sys_var *opt);