1
/* Copyright (C) 2005 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
19
#include <drizzled/global.h>
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
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/lex_string.h>
24
#include <drizzled/xid.h>
25
#include <drizzled/plugin/manifest.h>
26
#include <drizzled/plugin/module.h>
27
#include "drizzled/plugin/version.h"
28
#include "drizzled/definitions.h"
24
#define DRIZZLE_THD THD*
26
#define DRIZZLE_THD void*
31
/* This definition must match the one given in m_string.h */
32
struct st_mysql_lex_string
37
#endif /* _m_string_h */
38
typedef struct st_mysql_lex_string DRIZZLE_LEX_STRING;
40
#define DRIZZLE_XIDDATASIZE 128
42
struct st_mysql_xid is binary compatible with the XID structure as
43
in the X/Open CAE Specification, Distributed Transaction Processing:
44
The XA Specification, X/Open Company Ltd., 1991.
45
http://www.opengroup.org/bookstore/catalog/c193.htm
47
@see XID in sql/handler.h
53
char data[DRIZZLE_XIDDATASIZE]; /* Not \0-terminated */
55
typedef struct st_mysql_xid DRIZZLE_XID;
33
struct charset_info_st;
57
35
/*************************************************************************
58
36
Plugin API. Common for all plugin types.
62
The allowable types of plugins
64
#define DRIZZLE_DAEMON_PLUGIN 0 /* Daemon / Raw */
65
#define DRIZZLE_STORAGE_ENGINE_PLUGIN 1 /* Storage Engine */
66
#define DRIZZLE_INFORMATION_SCHEMA_PLUGIN 2 /* Information Schema */
67
#define DRIZZLE_UDF_PLUGIN 3 /* User-Defined Function */
68
#define DRIZZLE_UDA_PLUGIN 4 /* User-Defined Aggregate function */
69
#define DRIZZLE_AUDIT_PLUGIN 5 /* Audit */
70
#define DRIZZLE_LOGGER_PLUGIN 6 /* Logging */
71
#define DRIZZLE_AUTH_PLUGIN 7 /* Authorization */
73
#define DRIZZLE_MAX_PLUGIN_TYPE_NUM 8 /* The number of plugin types */
75
/* We use the following strings to define licenses for plugins */
76
#define PLUGIN_LICENSE_PROPRIETARY 0
77
#define PLUGIN_LICENSE_GPL 1
78
#define PLUGIN_LICENSE_BSD 2
80
#define PLUGIN_LICENSE_PROPRIETARY_STRING "PROPRIETARY"
81
#define PLUGIN_LICENSE_GPL_STRING "GPL"
82
#define PLUGIN_LICENSE_BSD_STRING "BSD"
85
Macros for beginning and ending plugin declarations. Between
86
mysql_declare_plugin and mysql_declare_plugin_end there should
87
be a st_mysql_plugin struct for each plugin to be declared.
91
#ifndef DRIZZLE_DYNAMIC_PLUGIN
92
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
93
struct st_mysql_plugin DECLS[]= {
95
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
96
struct st_mysql_plugin _mysql_plugin_declarations_[]= {
99
#define mysql_declare_plugin(NAME) \
100
__DRIZZLE_DECLARE_PLUGIN(NAME, \
101
builtin_ ## NAME ## _plugin)
103
#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0}}
41
typedef drizzle_lex_string LEX_STRING;
44
extern char *opt_plugin_add;
45
extern char *opt_plugin_load;
46
extern char *opt_plugin_dir_ptr;
47
extern char opt_plugin_dir[FN_REFLEN];
49
namespace drizzled { namespace plugin { class StorageEngine; } }
52
Macros for beginning and ending plugin declarations. Between
53
DRIZZLE_DECLARE_PLUGIN and DRIZZLE_DECLARE_PLUGIN_END there should
54
be a drizzled::plugin::Manifest for each plugin to be declared.
58
#define PANDORA_CPP_NAME(x) _drizzled_ ## x ## _plugin_
59
#define PANDORA_PLUGIN_NAME(x) PANDORA_CPP_NAME(x)
60
#define DRIZZLE_DECLARE_PLUGIN \
61
drizzled::plugin::Manifest PANDORA_PLUGIN_NAME(PANDORA_MODULE_NAME)=
64
#define DRIZZLE_DECLARE_PLUGIN_END
65
#define DRIZZLE_PLUGIN(init,deinit,status,system) \
66
DRIZZLE_DECLARE_PLUGIN \
69
STRINGIFY_ARG(PANDORA_MODULE_NAME), \
70
STRINGIFY_ARG(PANDORA_MODULE_VERSION), \
71
STRINGIFY_ARG(PANDORA_MODULE_AUTHOR), \
72
STRINGIFY_ARG(PANDORA_MODULE_TITLE), \
73
PANDORA_MODULE_LICENSE, \
74
init, deinit, status, system, NULL \
106
79
declarations for SHOW STATUS support in plugins
319
298
PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
320
299
#name, comment, check, update, &varname, def, typelib }
322
#define DRIZZLE_THDVAR_BOOL(name, opt, comment, check, update, def) \
323
DECLARE_DRIZZLE_THDVAR_BASIC(name, char) = { \
324
PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
325
#name, comment, check, update, -1, def, NULL}
327
#define DRIZZLE_THDVAR_STR(name, opt, comment, check, update, def) \
328
DECLARE_DRIZZLE_THDVAR_BASIC(name, char *) = { \
329
PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
330
#name, comment, check, update, -1, def, NULL}
332
#define DRIZZLE_THDVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
333
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, int) = { \
334
PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
335
#name, comment, check, update, -1, def, min, max, blk, NULL }
337
#define DRIZZLE_THDVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
338
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, unsigned int) = { \
339
PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
340
#name, comment, check, update, -1, def, min, max, blk, NULL }
342
#define DRIZZLE_THDVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
343
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, long) = { \
344
PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
345
#name, comment, check, update, -1, def, min, max, blk, NULL }
347
#define DRIZZLE_THDVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
348
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, unsigned long) = { \
349
PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
350
#name, comment, check, update, -1, def, min, max, blk, NULL }
352
#define DRIZZLE_THDVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
353
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, int64_t) = { \
354
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
355
#name, comment, check, update, -1, def, min, max, blk, NULL }
357
#define DRIZZLE_THDVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
358
DECLARE_DRIZZLE_THDVAR_SIMPLE(name, uint64_t) = { \
359
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
360
#name, comment, check, update, -1, def, min, max, blk, NULL }
362
#define DRIZZLE_THDVAR_ENUM(name, opt, comment, check, update, def, typelib) \
363
DECLARE_DRIZZLE_THDVAR_TYPELIB(name, unsigned long) = { \
364
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), \
365
344
#name, comment, check, update, -1, def, NULL, typelib }
367
#define DRIZZLE_THDVAR_SET(name, opt, comment, check, update, def, typelib) \
368
DECLARE_DRIZZLE_THDVAR_TYPELIB(name, uint64_t) = { \
369
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), \
370
349
#name, comment, check, update, -1, def, NULL, typelib }
372
351
/* accessor macros */
495
477
@see alloc_root()
497
void *thd_alloc(DRIZZLE_THD thd, unsigned int size);
501
void *thd_calloc(DRIZZLE_THD thd, unsigned int size);
505
char *thd_strdup(DRIZZLE_THD thd, const char *str);
509
char *thd_strmake(DRIZZLE_THD thd, const char *str, unsigned int size);
513
void *thd_memdup(DRIZZLE_THD thd, const void* str, unsigned int size);
516
Create a LEX_STRING in this connection's local memory pool
518
@param thd user thread connection handle
519
@param lex_str pointer to LEX_STRING object to be initialized
520
@param str initializer to be copied into lex_str
521
@param size length of str, in bytes
522
@param allocate_lex_string flag: if TRUE, allocate new LEX_STRING object,
523
instead of using lex_str value
524
@return NULL on failure, or pointer to the LEX_STRING object
528
DRIZZLE_LEX_STRING *thd_make_lex_string(DRIZZLE_THD thd, DRIZZLE_LEX_STRING *lex_str,
529
const char *str, unsigned int size,
530
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);
533
498
Get the XID for this connection's transaction
535
@param thd user thread connection handle
500
@param session user thread connection handle
536
501
@param xid location where identifier is stored
538
void thd_get_xid(const DRIZZLE_THD thd, DRIZZLE_XID *xid);
503
void session_get_xid(const Session *session, DRIZZLE_XID *xid);
541
506
Invalidate the query cache for a given table.
543
@param thd user thread connection handle
508
@param session user thread connection handle
544
509
@param key databasename\\0tablename\\0
545
510
@param key_length length of key in bytes, including the NUL bytes
546
511
@param using_trx flag: TRUE if using transactions, FALSE otherwise
548
void mysql_query_cache_invalidate4(DRIZZLE_THD thd,
513
void mysql_query_cache_invalidate4(Session *session,
549
514
const char *key, unsigned int key_length,