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;
28
struct charset_info_st;
61
30
/*************************************************************************
62
31
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
/* 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
84
#define PLUGIN_LICENSE_PROPRIETARY_STRING "PROPRIETARY"
85
#define PLUGIN_LICENSE_GPL_STRING "GPL"
86
#define PLUGIN_LICENSE_BSD_STRING "BSD"
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.
95
#ifndef DRIZZLE_DYNAMIC_PLUGIN
36
Macros for beginning and ending plugin declarations. Between
37
drizzle_declare_plugin and drizzle_declare_plugin_end there should
38
be a drizzled::plugin::Manifest for each plugin to be declared.
42
#ifndef PANDORA_DYNAMIC_PLUGIN
96
43
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
97
struct st_mysql_plugin DECLS[]= {
44
drizzled::plugin::Manifest DECLS[]= {
99
46
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
100
struct st_mysql_plugin _mysql_plugin_declarations_[]= {
47
drizzled::plugin::Manifest _drizzled_plugin_declaration_[]= {
103
#define mysql_declare_plugin(NAME) \
50
#define drizzle_declare_plugin(NAME) \
104
51
__DRIZZLE_DECLARE_PLUGIN(NAME, \
105
52
builtin_ ## NAME ## _plugin)
107
#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0}}
54
#define drizzle_declare_plugin_end ,{0,0,0,0,PLUGIN_LICENSE_GPL,0,0,0,0,0}}
59
the following flags are valid for plugin_init()
61
#define PLUGIN_INIT_SKIP_DYNAMIC_LOADING 1
62
#define PLUGIN_INIT_SKIP_PLUGIN_TABLE 2
63
#define PLUGIN_INIT_SKIP_INITIALIZATION 4
65
#define INITIAL_LEX_PLUGIN_LIST_SIZE 16
110
68
declarations for SHOW STATUS support in plugins
323
287
PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
324
288
#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), \
290
#define DRIZZLE_SessionVAR_BOOL(name, opt, comment, check, update, def) \
291
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char) = { \
292
PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
293
#name, comment, check, update, -1, def, NULL}
295
#define DRIZZLE_SessionVAR_STR(name, opt, comment, check, update, def) \
296
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char *) = { \
297
PLUGIN_VAR_STR | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
298
#name, comment, check, update, -1, def, NULL}
300
#define DRIZZLE_SessionVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
301
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int) = { \
302
PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
303
#name, comment, check, update, -1, def, min, max, blk, NULL }
305
#define DRIZZLE_SessionVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
306
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned int) = { \
307
PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
308
#name, comment, check, update, -1, def, min, max, blk, NULL }
310
#define DRIZZLE_SessionVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
311
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, long) = { \
312
PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
313
#name, comment, check, update, -1, def, min, max, blk, NULL }
315
#define DRIZZLE_SessionVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
316
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned long) = { \
317
PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
318
#name, comment, check, update, -1, def, min, max, blk, NULL }
320
#define DRIZZLE_SessionVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
321
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int64_t) = { \
322
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
323
#name, comment, check, update, -1, def, min, max, blk, NULL }
325
#define DRIZZLE_SessionVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
326
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, uint64_t) = { \
327
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
328
#name, comment, check, update, -1, def, min, max, blk, NULL }
330
#define DRIZZLE_SessionVAR_ENUM(name, opt, comment, check, update, def, typelib) \
331
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, unsigned long) = { \
332
PLUGIN_VAR_ENUM | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
369
333
#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), \
335
#define DRIZZLE_SessionVAR_SET(name, opt, comment, check, update, def, typelib) \
336
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, uint64_t) = { \
337
PLUGIN_VAR_SET | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
374
338
#name, comment, check, update, -1, def, NULL, typelib }
376
340
/* accessor macros */
499
477
@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);
479
void *session_alloc(Session *session, unsigned int size);
483
void *session_calloc(Session *session, unsigned int size);
487
char *session_strdup(Session *session, const char *str);
491
char *session_strmake(Session *session, const char *str, unsigned int size);
495
void *session_memdup(Session *session, const void* str, unsigned int size);
537
498
Get the XID for this connection's transaction
539
@param thd user thread connection handle
500
@param session user thread connection handle
540
501
@param xid location where identifier is stored
542
void thd_get_xid(const DRIZZLE_THD thd, DRIZZLE_XID *xid);
503
void session_get_xid(const Session *session, DRIZZLE_XID *xid);
545
506
Invalidate the query cache for a given table.
547
@param thd user thread connection handle
508
@param session user thread connection handle
548
509
@param key databasename\\0tablename\\0
549
510
@param key_length length of key in bytes, including the NUL bytes
550
511
@param using_trx flag: TRUE if using transactions, FALSE otherwise
552
void mysql_query_cache_invalidate4(DRIZZLE_THD thd,
513
void mysql_query_cache_invalidate4(Session *session,
553
514
const char *key, unsigned int key_length,