17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
#include <drizzled/global.h>
20
#ifndef DRIZZLED_PLUGIN_H
21
#define DRIZZLED_PLUGIN_H
23
#include <drizzled/lex_string.h>
24
#include <drizzled/xid.h>
28
#define DRIZZLE_THD THD*
30
#define DRIZZLE_THD void*
35
/* This definition must match the one given in m_string.h */
36
struct st_mysql_lex_string
41
#endif /* _m_string_h */
42
typedef struct st_mysql_lex_string DRIZZLE_LEX_STRING;
44
#define DRIZZLE_XIDDATASIZE 128
46
struct st_mysql_xid is binary compatible with the XID structure as
47
in the X/Open CAE Specification, Distributed Transaction Processing:
48
The XA Specification, X/Open Company Ltd., 1991.
49
http://www.opengroup.org/bookstore/catalog/c193.htm
51
@see XID in sql/handler.h
57
char data[DRIZZLE_XIDDATASIZE]; /* Not \0-terminated */
59
typedef struct st_mysql_xid DRIZZLE_XID;
61
29
/*************************************************************************
62
30
Plugin API. Common for all plugin types.
66
The allowable types of plugins
68
#define DRIZZLE_DAEMON_PLUGIN 0 /* Daemon / Raw */
69
#define DRIZZLE_STORAGE_ENGINE_PLUGIN 1 /* Storage Engine */
70
#define DRIZZLE_INFORMATION_SCHEMA_PLUGIN 2 /* Information Schema */
71
#define DRIZZLE_UDF_PLUGIN 3 /* User-Defined Function */
72
#define DRIZZLE_UDA_PLUGIN 4 /* User-Defined Aggregate function */
73
#define DRIZZLE_AUDIT_PLUGIN 5 /* Audit */
74
#define DRIZZLE_LOGGER_PLUGIN 6 /* Logging */
75
#define DRIZZLE_AUTH_PLUGIN 7 /* Authorization */
77
#define DRIZZLE_MAX_PLUGIN_TYPE_NUM 8 /* The number of plugin types */
79
34
/* We use the following strings to define licenses for plugins */
80
#define PLUGIN_LICENSE_PROPRIETARY 0
81
#define PLUGIN_LICENSE_GPL 1
82
#define PLUGIN_LICENSE_BSD 2
35
enum plugin_license_type {
36
PLUGIN_LICENSE_PROPRIETARY,
40
PLUGIN_LICENSE_MAX=PLUGIN_LICENSE_LGPL
84
#define PLUGIN_LICENSE_PROPRIETARY_STRING "PROPRIETARY"
85
#define PLUGIN_LICENSE_GPL_STRING "GPL"
86
#define PLUGIN_LICENSE_BSD_STRING "BSD"
43
const char * const PLUGIN_LICENSE_PROPRIETARY_STRING="PROPRIETARY";
44
const char * const PLUGIN_LICENSE_GPL_STRING="GPL";
45
const char * const PLUGIN_LICENSE_BSD_STRING="BSD";
46
const char * const PLUGIN_LICENSE_LGPL_STRING="LGPL";
89
Macros for beginning and ending plugin declarations. Between
90
mysql_declare_plugin and mysql_declare_plugin_end there should
91
be a st_mysql_plugin struct for each plugin to be declared.
49
Macros for beginning and ending plugin declarations. Between
50
drizzle_declare_plugin and drizzle_declare_plugin_end there should
51
be a drizzled_plugin_manifest struct for each plugin to be declared.
95
55
#ifndef DRIZZLE_DYNAMIC_PLUGIN
96
56
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
97
struct st_mysql_plugin DECLS[]= {
57
struct drizzled_plugin_manifest DECLS[]= {
99
59
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
100
struct st_mysql_plugin _mysql_plugin_declarations_[]= {
60
struct drizzled_plugin_manifest _mysql_plugin_declarations_[]= {
103
#define mysql_declare_plugin(NAME) \
63
#define drizzle_declare_plugin(NAME) \
104
64
__DRIZZLE_DECLARE_PLUGIN(NAME, \
105
65
builtin_ ## NAME ## _plugin)
107
#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0}}
67
#define drizzle_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0}}
70
the following flags are valid for plugin_init()
72
#define PLUGIN_INIT_SKIP_DYNAMIC_LOADING 1
73
#define PLUGIN_INIT_SKIP_PLUGIN_TABLE 2
74
#define PLUGIN_INIT_SKIP_INITIALIZATION 4
76
#define INITIAL_LEX_PLUGIN_LIST_SIZE 16
110
79
declarations for SHOW STATUS support in plugins
323
298
PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
324
299
#name, comment, check, update, &varname, def, typelib }
326
#define DRIZZLE_THDVAR_BOOL(name, opt, comment, check, update, def) \
327
DECLARE_DRIZZLE_THDVAR_BASIC(name, char) = { \
328
PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
329
#name, comment, check, update, -1, def, NULL}
331
#define DRIZZLE_THDVAR_STR(name, opt, comment, check, update, def) \
332
DECLARE_DRIZZLE_THDVAR_BASIC(name, char *) = { \
333
PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
334
#name, comment, check, update, -1, def, NULL}
336
#define DRIZZLE_THDVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
337
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, int) = { \
338
PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
339
#name, comment, check, update, -1, def, min, max, blk, NULL }
341
#define DRIZZLE_THDVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
342
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, unsigned int) = { \
343
PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
344
#name, comment, check, update, -1, def, min, max, blk, NULL }
346
#define DRIZZLE_THDVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
347
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, long) = { \
348
PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
349
#name, comment, check, update, -1, def, min, max, blk, NULL }
351
#define DRIZZLE_THDVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
352
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, unsigned long) = { \
353
PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
354
#name, comment, check, update, -1, def, min, max, blk, NULL }
356
#define DRIZZLE_THDVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
357
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, int64_t) = { \
358
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
359
#name, comment, check, update, -1, def, min, max, blk, NULL }
361
#define DRIZZLE_THDVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
362
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, uint64_t) = { \
363
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
364
#name, comment, check, update, -1, def, min, max, blk, NULL }
366
#define DRIZZLE_THDVAR_ENUM(name, opt, comment, check, update, def, typelib) \
367
DECLARE_DRIZZLE_THDVAR_TYPELIB(name, unsigned long) = { \
368
PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
301
#define DRIZZLE_SessionVAR_BOOL(name, opt, comment, check, update, def) \
302
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char) = { \
303
PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
304
#name, comment, check, update, -1, def, NULL}
306
#define DRIZZLE_SessionVAR_STR(name, opt, comment, check, update, def) \
307
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char *) = { \
308
PLUGIN_VAR_STR | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
309
#name, comment, check, update, -1, def, NULL}
311
#define DRIZZLE_SessionVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
312
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int) = { \
313
PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
314
#name, comment, check, update, -1, def, min, max, blk, NULL }
316
#define DRIZZLE_SessionVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
317
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned int) = { \
318
PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
319
#name, comment, check, update, -1, def, min, max, blk, NULL }
321
#define DRIZZLE_SessionVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
322
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, long) = { \
323
PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
324
#name, comment, check, update, -1, def, min, max, blk, NULL }
326
#define DRIZZLE_SessionVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
327
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned long) = { \
328
PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
329
#name, comment, check, update, -1, def, min, max, blk, NULL }
331
#define DRIZZLE_SessionVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
332
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int64_t) = { \
333
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
334
#name, comment, check, update, -1, def, min, max, blk, NULL }
336
#define DRIZZLE_SessionVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
337
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, uint64_t) = { \
338
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
339
#name, comment, check, update, -1, def, min, max, blk, NULL }
341
#define DRIZZLE_SessionVAR_ENUM(name, opt, comment, check, update, def, typelib) \
342
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, unsigned long) = { \
343
PLUGIN_VAR_ENUM | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
369
344
#name, comment, check, update, -1, def, NULL, typelib }
371
#define DRIZZLE_THDVAR_SET(name, opt, comment, check, update, def, typelib) \
372
DECLARE_DRIZZLE_THDVAR_TYPELIB(name, uint64_t) = { \
373
PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
346
#define DRIZZLE_SessionVAR_SET(name, opt, comment, check, update, def, typelib) \
347
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, uint64_t) = { \
348
PLUGIN_VAR_SET | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
374
349
#name, comment, check, update, -1, def, NULL, typelib }
376
351
/* accessor macros */
499
483
@see alloc_root()
501
void *thd_alloc(DRIZZLE_THD thd, unsigned int size);
505
void *thd_calloc(DRIZZLE_THD thd, unsigned int size);
509
char *thd_strdup(DRIZZLE_THD thd, const char *str);
513
char *thd_strmake(DRIZZLE_THD thd, const char *str, unsigned int size);
517
void *thd_memdup(DRIZZLE_THD thd, const void* str, unsigned int size);
520
Create a LEX_STRING in this connection's local memory pool
522
@param thd user thread connection handle
523
@param lex_str pointer to LEX_STRING object to be initialized
524
@param str initializer to be copied into lex_str
525
@param size length of str, in bytes
526
@param allocate_lex_string flag: if TRUE, allocate new LEX_STRING object,
527
instead of using lex_str value
528
@return NULL on failure, or pointer to the LEX_STRING object
532
DRIZZLE_LEX_STRING *thd_make_lex_string(DRIZZLE_THD thd, DRIZZLE_LEX_STRING *lex_str,
533
const char *str, unsigned int size,
534
int allocate_lex_string);
485
void *session_alloc(Session *session, unsigned int size);
489
void *session_calloc(Session *session, unsigned int size);
493
char *session_strdup(Session *session, const char *str);
497
char *session_strmake(Session *session, const char *str, unsigned int size);
501
void *session_memdup(Session *session, const void* str, unsigned int size);
537
504
Get the XID for this connection's transaction
539
@param thd user thread connection handle
506
@param session user thread connection handle
540
507
@param xid location where identifier is stored
542
void thd_get_xid(const DRIZZLE_THD thd, DRIZZLE_XID *xid);
509
void session_get_xid(const Session *session, DRIZZLE_XID *xid);
545
512
Invalidate the query cache for a given table.
547
@param thd user thread connection handle
514
@param session user thread connection handle
548
515
@param key databasename\\0tablename\\0
549
516
@param key_length length of key in bytes, including the NUL bytes
550
517
@param using_trx flag: TRUE if using transactions, FALSE otherwise
552
void mysql_query_cache_invalidate4(DRIZZLE_THD thd,
519
void mysql_query_cache_invalidate4(Session *session,
553
520
const char *key, unsigned int key_length,