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
void plugin_opt_set_limits(option *options, const drizzle_sys_var *opt);
359
void plugin_opt_set_limits(my_option *options, const drizzle_sys_var *opt);
161
361
struct drizzle_value
200
408
@retval >= 0 a file handle that can be passed to dup or internal::my_close
202
DRIZZLED_API int tmpfile(const char *prefix);
410
int mysql_tmpfile(const char *prefix);
413
Check the killed state of a connection
416
In MySQL support for the KILL statement is cooperative. The KILL
417
statement only sets a "killed" flag. This function returns the value
418
of that flag. A thread should check it often, especially inside
419
time-consuming loops, and gracefully abort the operation if it is
422
@param session user thread connection handle
423
@retval 0 the connection is active
424
@retval 1 the connection has been killed
426
int session_killed(const Session *session);
430
Return the thread id of a user thread
432
@param session user thread connection handle
435
unsigned long session_get_thread_id(const Session *session);
437
const charset_info_st *session_charset(Session *session);
438
int session_non_transactional_update(const Session *session);
439
void session_mark_transaction_to_rollback(Session *session, bool all);
443
Allocate memory in the connection's local memory pool
446
When properly used in place of @c malloc(), this can significantly
447
improve concurrency. Don't use this or related functions to allocate
448
large chunks of memory. Use for temporary storage only. The memory
449
will be freed automatically at the end of the statement; no explicit
450
code is required to prevent memory leaks.
454
void *session_alloc(Session *session, unsigned int size);
458
void *session_calloc(Session *session, unsigned int size);
462
char *session_strdup(Session *session, const char *str);
466
char *session_strmake(Session *session, const char *str, unsigned int size);
470
void *session_memdup(Session *session, const void* str, unsigned int size);
473
Get the XID for this connection's transaction
475
@param session user thread connection handle
476
@param xid location where identifier is stored
478
void session_get_xid(const Session *session, DRIZZLE_XID *xid);
481
Invalidate the query cache for a given table.
483
@param session user thread connection handle
484
@param key databasename\\0tablename\\0
485
@param key_length length of key in bytes, including the NUL bytes
486
@param using_trx flag: TRUE if using transactions, FALSE otherwise
488
void mysql_query_cache_invalidate4(Session *session,
489
const char *key, unsigned int key_length,
204
496
} /* namespace drizzled */