17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#ifndef DRIZZLED_PLUGIN_H
21
#define DRIZZLED_PLUGIN_H
23
#include "drizzled/module/manifest.h"
24
#include "drizzled/module/module.h"
25
#include "drizzled/plugin/version.h"
26
#include "drizzled/module/context.h"
27
#include "drizzled/definitions.h"
29
#include "drizzled/lex_string.h"
30
#include "drizzled/xid.h"
31
#include <boost/program_options.hpp>
23
#include <drizzled/global.h>
38
struct charset_info_st;
28
#define DRIZZLE_THD THD*
30
#define DRIZZLE_THD void*
33
#define DRIZZLE_XIDDATASIZE 128
35
struct st_mysql_xid is binary compatible with the XID structure as
36
in the X/Open CAE Specification, Distributed Transaction Processing:
37
The XA Specification, X/Open Company Ltd., 1991.
38
http://www.opengroup.org/bookstore/catalog/c193.htm
40
@see XID in sql/handler.h
46
char data[DRIZZLE_XIDDATASIZE]; /* Not \0-terminated */
48
typedef struct st_mysql_xid DRIZZLE_XID;
40
50
/*************************************************************************
41
51
Plugin API. Common for all plugin types.
46
typedef drizzle_lex_string LEX_STRING;
49
extern char *opt_plugin_dir_ptr;
50
extern char opt_plugin_dir[FN_REFLEN];
52
namespace plugin { class StorageEngine; }
55
Macros for beginning and ending plugin declarations. Between
56
DRIZZLE_DECLARE_PLUGIN and DRIZZLE_DECLARE_PLUGIN_END there should
57
be a module::Manifest for each plugin to be declared.
61
#define PANDORA_CPP_NAME(x) _drizzled_ ## x ## _plugin_
62
#define PANDORA_PLUGIN_NAME(x) PANDORA_CPP_NAME(x)
63
#define DRIZZLE_DECLARE_PLUGIN \
64
::drizzled::module::Manifest PANDORA_PLUGIN_NAME(PANDORA_MODULE_NAME)=
67
#define DRIZZLE_DECLARE_PLUGIN_END
68
#define DRIZZLE_PLUGIN(init,system,options) \
69
DRIZZLE_DECLARE_PLUGIN \
72
STRINGIFY_ARG(PANDORA_MODULE_NAME), \
73
STRINGIFY_ARG(PANDORA_MODULE_VERSION), \
74
STRINGIFY_ARG(PANDORA_MODULE_AUTHOR), \
75
STRINGIFY_ARG(PANDORA_MODULE_TITLE), \
76
PANDORA_MODULE_LICENSE, \
77
init, system, options \
55
The allowable types of plugins
57
#define DRIZZLE_DAEMON_PLUGIN 0 /* Daemon / Raw */
58
#define DRIZZLE_STORAGE_ENGINE_PLUGIN 1 /* Storage Engine */
59
#define DRIZZLE_INFORMATION_SCHEMA_PLUGIN 2 /* Information Schema */
60
#define DRIZZLE_UDF_PLUGIN 3 /* User-Defined Function */
61
#define DRIZZLE_UDA_PLUGIN 4 /* User-Defined Aggregate function */
62
#define DRIZZLE_AUDIT_PLUGIN 5 /* Audit */
63
#define DRIZZLE_LOGGER_PLUGIN 6 /* Logging */
64
#define DRIZZLE_AUTH_PLUGIN 7 /* Authorization */
66
#define DRIZZLE_MAX_PLUGIN_TYPE_NUM 8 /* The number of plugin types */
68
/* We use the following strings to define licenses for plugins */
69
#define PLUGIN_LICENSE_PROPRIETARY 0
70
#define PLUGIN_LICENSE_GPL 1
71
#define PLUGIN_LICENSE_BSD 2
73
#define PLUGIN_LICENSE_PROPRIETARY_STRING "PROPRIETARY"
74
#define PLUGIN_LICENSE_GPL_STRING "GPL"
75
#define PLUGIN_LICENSE_BSD_STRING "BSD"
78
Macros for beginning and ending plugin declarations. Between
79
mysql_declare_plugin and mysql_declare_plugin_end there should
80
be a st_mysql_plugin struct for each plugin to be declared.
84
#ifndef DRIZZLE_DYNAMIC_PLUGIN
85
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
86
struct st_mysql_plugin DECLS[]= {
88
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
89
struct st_mysql_plugin _mysql_plugin_declarations_[]= {
92
#define mysql_declare_plugin(NAME) \
93
__DRIZZLE_DECLARE_PLUGIN(NAME, \
94
builtin_ ## NAME ## _plugin)
96
#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0}}
82
99
declarations for SHOW STATUS support in plugins
282
302
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
283
303
#name, comment, check, update, &varname, def, min, max, blk }
285
#define DRIZZLE_SessionVAR_BOOL(name, opt, comment, check, update, def) \
286
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char) = { \
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 }
305
#define DRIZZLE_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \
306
DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, unsigned long) = { \
307
PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \
308
#name, comment, check, update, &varname, def, typelib }
310
#define DRIZZLE_SYSVAR_SET(name, varname, opt, comment, check, update, def, typelib) \
311
DECLARE_DRIZZLE_SYSVAR_TYPELIB(name, uint64_t) = { \
312
PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
313
#name, comment, check, update, &varname, def, typelib }
315
#define DRIZZLE_THDVAR_BOOL(name, opt, comment, check, update, def) \
316
DECLARE_DRIZZLE_THDVAR_BASIC(name, char) = { \
317
PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
318
#name, comment, check, update, -1, def, NULL}
320
#define DRIZZLE_THDVAR_STR(name, opt, comment, check, update, def) \
321
DECLARE_DRIZZLE_THDVAR_BASIC(name, char *) = { \
322
PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
323
#name, comment, check, update, -1, def, NULL}
325
#define DRIZZLE_THDVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
326
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, int) = { \
327
PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
328
#name, comment, check, update, -1, def, min, max, blk, NULL }
330
#define DRIZZLE_THDVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
331
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, unsigned int) = { \
332
PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
333
#name, comment, check, update, -1, def, min, max, blk, NULL }
335
#define DRIZZLE_THDVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
336
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, long) = { \
337
PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
338
#name, comment, check, update, -1, def, min, max, blk, NULL }
340
#define DRIZZLE_THDVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
341
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, unsigned long) = { \
342
PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
343
#name, comment, check, update, -1, def, min, max, blk, NULL }
345
#define DRIZZLE_THDVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
346
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, int64_t) = { \
347
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
348
#name, comment, check, update, -1, def, min, max, blk, NULL }
350
#define DRIZZLE_THDVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
351
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, uint64_t) = { \
352
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
353
#name, comment, check, update, -1, def, min, max, blk, NULL }
355
#define DRIZZLE_THDVAR_ENUM(name, opt, comment, check, update, def, typelib) \
356
DECLARE_DRIZZLE_THDVAR_TYPELIB(name, unsigned long) = { \
357
PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
358
#name, comment, check, update, -1, def, NULL, typelib }
360
#define DRIZZLE_THDVAR_SET(name, opt, comment, check, update, def, typelib) \
361
DECLARE_DRIZZLE_THDVAR_TYPELIB(name, uint64_t) = { \
362
PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
363
#name, comment, check, update, -1, def, NULL, typelib }
325
365
/* accessor macros */
327
367
#define SYSVAR(name) \
328
368
(*(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)))
370
/* when thd == null, result points to global value */
371
#define THDVAR(thd, name) \
372
(*(DRIZZLE_SYSVAR_NAME(name).resolve(thd, DRIZZLE_SYSVAR_NAME(name).offset)))
376
Plugin description structure.
379
struct st_mysql_plugin
381
int type; /* the plugin type (a DRIZZLE_XXX_PLUGIN value) */
382
const char *name; /* plugin name (for SHOW PLUGINS) */
383
const char *version; /* plugin version (for SHOW PLUGINS) */
384
const char *author; /* plugin author (for SHOW PLUGINS) */
385
const char *descr; /* general descriptive text (for SHOW PLUGINS ) */
386
int license; /* the plugin license (PLUGIN_LICENSE_XXX) */
387
int (*init)(void *); /* the function to invoke when plugin is loaded */
388
int (*deinit)(void *);/* the function to invoke when plugin is unloaded */
389
struct st_mysql_show_var *status_vars;
390
struct st_mysql_sys_var **system_vars;
391
void * __reserved1; /* reserved for dependency checking */
335
397
/*************************************************************************
336
drizzle_value struct for reading values from mysqld.
398
st_mysql_value struct for reading values from mysqld.
337
399
Used by server variables framework to parse user-provided values.
338
400
Will be used for arguments when implementing UDFs.
415
458
time-consuming loops, and gracefully abort the operation if it is
418
@param session user thread connection handle
461
@param thd user thread connection handle
419
462
@retval 0 the connection is active
420
463
@retval 1 the connection has been killed
422
int session_killed(const Session *session);
425
const charset_info_st *session_charset(Session *session);
465
int thd_killed(const DRIZZLE_THD thd);
469
Return the thread id of a user thread
471
@param thd user thread connection handle
474
unsigned long thd_get_thread_id(const DRIZZLE_THD thd);
478
Allocate memory in the connection's local memory pool
481
When properly used in place of @c my_malloc(), this can significantly
482
improve concurrency. Don't use this or related functions to allocate
483
large chunks of memory. Use for temporary storage only. The memory
484
will be freed automatically at the end of the statement; no explicit
485
code is required to prevent memory leaks.
489
void *thd_alloc(DRIZZLE_THD thd, unsigned int size);
493
void *thd_calloc(DRIZZLE_THD thd, unsigned int size);
497
char *thd_strdup(DRIZZLE_THD thd, const char *str);
501
char *thd_strmake(DRIZZLE_THD thd, const char *str, unsigned int size);
505
void *thd_memdup(DRIZZLE_THD thd, const void* str, unsigned int size);
508
Get the XID for this connection's transaction
510
@param thd user thread connection handle
511
@param xid location where identifier is stored
513
void thd_get_xid(const DRIZZLE_THD thd, DRIZZLE_XID *xid);
428
516
Invalidate the query cache for a given table.
430
@param session user thread connection handle
518
@param thd user thread connection handle
431
519
@param key databasename\\0tablename\\0
432
520
@param key_length length of key in bytes, including the NUL bytes
433
521
@param using_trx flag: TRUE if using transactions, FALSE otherwise
435
void mysql_query_cache_invalidate4(Session *session,
523
void mysql_query_cache_invalidate4(DRIZZLE_THD thd,
436
524
const char *key, unsigned int key_length,
439
} /* namespace drizzled */
441
#endif /* DRIZZLED_PLUGIN_H */
533
Provide a handler data getter to simplify coding
537
thd_get_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton)
539
return *thd_ha_data(thd, hton);
543
Provide a handler data setter to simplify coding
547
thd_set_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton,
550
*thd_ha_data(thd, hton)= (void*) ha_data;