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/library.h>
27
#include <drizzled/plugin/module.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;
31
struct charset_info_st;
57
33
/*************************************************************************
58
34
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[]= {
39
typedef struct st_mysql_lex_string LEX_STRING;
42
extern char *opt_plugin_add;
43
extern char *opt_plugin_load;
44
extern char *opt_plugin_dir_ptr;
45
extern char opt_plugin_dir[FN_REFLEN];
47
namespace drizzled { namespace plugin { class StorageEngine; } }
50
Macros for beginning and ending plugin declarations. Between
51
drizzle_declare_plugin and drizzle_declare_plugin_end there should
52
be a drizzled::plugin::Manifest for each plugin to be declared.
56
#if defined(PANDORA_DYNAMIC_PLUGIN)
57
# define drizzle_declare_plugin \
58
drizzled::plugin::Manifest _drizzled_plugin_declaration_[]= {
95
#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
96
struct st_mysql_plugin _mysql_plugin_declarations_[]= {
60
# define PANDORA_BUILTIN_NAME(x) builtin_ ## x ## _plugin
61
# define PANDORA_NAME(x) PANDORA_BUILTIN_NAME(x)
62
# define drizzle_declare_plugin \
63
drizzled::plugin::Manifest PANDORA_NAME(PANDORA_MODULE_NAME)[]= {
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}}
67
#define drizzle_declare_plugin_end ,{0,0,0,0,PLUGIN_LICENSE_GPL,0,0,0,0,0}}
72
the following flags are valid for plugin_init()
74
#define PLUGIN_INIT_SKIP_DYNAMIC_LOADING 1
75
#define PLUGIN_INIT_SKIP_PLUGIN_TABLE 2
76
#define PLUGIN_INIT_SKIP_INITIALIZATION 4
78
#define INITIAL_LEX_PLUGIN_LIST_SIZE 16
106
81
declarations for SHOW STATUS support in plugins
319
300
PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
320
301
#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), \
303
#define DRIZZLE_SessionVAR_BOOL(name, opt, comment, check, update, def) \
304
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char) = { \
305
PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
306
#name, comment, check, update, -1, def, NULL}
308
#define DRIZZLE_SessionVAR_STR(name, opt, comment, check, update, def) \
309
DECLARE_DRIZZLE_SessionVAR_BASIC(name, char *) = { \
310
PLUGIN_VAR_STR | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
311
#name, comment, check, update, -1, def, NULL}
313
#define DRIZZLE_SessionVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
314
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int) = { \
315
PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
316
#name, comment, check, update, -1, def, min, max, blk, NULL }
318
#define DRIZZLE_SessionVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
319
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned int) = { \
320
PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
321
#name, comment, check, update, -1, def, min, max, blk, NULL }
323
#define DRIZZLE_SessionVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
324
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, long) = { \
325
PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
326
#name, comment, check, update, -1, def, min, max, blk, NULL }
328
#define DRIZZLE_SessionVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
329
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, unsigned long) = { \
330
PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
331
#name, comment, check, update, -1, def, min, max, blk, NULL }
333
#define DRIZZLE_SessionVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
334
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, int64_t) = { \
335
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
336
#name, comment, check, update, -1, def, min, max, blk, NULL }
338
#define DRIZZLE_SessionVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
339
DECLARE_DRIZZLE_SessionVAR_SIMPLE(name, uint64_t) = { \
340
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
341
#name, comment, check, update, -1, def, min, max, blk, NULL }
343
#define DRIZZLE_SessionVAR_ENUM(name, opt, comment, check, update, def, typelib) \
344
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, unsigned long) = { \
345
PLUGIN_VAR_ENUM | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
365
346
#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), \
348
#define DRIZZLE_SessionVAR_SET(name, opt, comment, check, update, def, typelib) \
349
DECLARE_DRIZZLE_SessionVAR_TYPELIB(name, uint64_t) = { \
350
PLUGIN_VAR_SET | PLUGIN_VAR_SessionLOCAL | ((opt) & PLUGIN_VAR_MASK), \
370
351
#name, comment, check, update, -1, def, NULL, typelib }
372
353
/* accessor macros */
435
int thd_in_lock_tables(const DRIZZLE_THD thd);
436
int thd_tablespace_op(const DRIZZLE_THD thd);
437
int64_t thd_test_options(const DRIZZLE_THD thd, int64_t test_options);
438
int thd_sql_command(const DRIZZLE_THD thd);
439
const char *thd_proc_info(DRIZZLE_THD thd, const char *info);
440
void **thd_ha_data(const DRIZZLE_THD thd, const struct handlerton *hton);
441
int thd_tx_isolation(const DRIZZLE_THD thd);
442
/* Increments the row counter, see THD::row_count */
443
void thd_inc_row_count(DRIZZLE_THD thd);
394
extern int plugin_init(drizzled::plugin::Registry &plugins,
395
int *argc, char **argv, int init_flags);
396
extern void plugin_shutdown(drizzled::plugin::Registry &plugins);
397
extern void my_print_help_inc_plugins(my_option *options);
398
extern bool plugin_is_ready(const LEX_STRING *name, int type);
399
extern bool mysql_install_plugin(Session *session, const LEX_STRING *name,
400
const LEX_STRING *dl);
401
extern bool mysql_uninstall_plugin(Session *session, const LEX_STRING *name);
402
extern void plugin_sessionvar_init(Session *session);
403
extern void plugin_sessionvar_cleanup(Session *session);
404
extern sys_var *intern_find_sys_var(const char *str, uint32_t, bool no_error);
406
int session_in_lock_tables(const Session *session);
407
int session_tablespace_op(const Session *session);
408
void set_session_proc_info(Session *session, const char *info);
409
const char *get_session_proc_info(Session *session);
410
int64_t session_test_options(const Session *session, int64_t test_options);
411
int session_sql_command(const Session *session);
412
void **session_ha_data(const Session *session, const drizzled::plugin::StorageEngine *engine);
413
int session_tx_isolation(const Session *session);
414
/* Increments the row counter, see Session::row_count */
415
void session_inc_row_count(Session *session);
417
LEX_STRING *session_make_lex_string(Session *session, LEX_STRING *lex_str,
418
const char *str, unsigned int size,
419
int allocate_lex_string);
446
424
Create a temporary file.
495
478
@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);
480
void *session_alloc(Session *session, unsigned int size);
484
void *session_calloc(Session *session, unsigned int size);
488
char *session_strdup(Session *session, const char *str);
492
char *session_strmake(Session *session, const char *str, unsigned int size);
496
void *session_memdup(Session *session, const void* str, unsigned int size);
533
499
Get the XID for this connection's transaction
535
@param thd user thread connection handle
501
@param session user thread connection handle
536
502
@param xid location where identifier is stored
538
void thd_get_xid(const DRIZZLE_THD thd, DRIZZLE_XID *xid);
504
void session_get_xid(const Session *session, DRIZZLE_XID *xid);
541
507
Invalidate the query cache for a given table.
543
@param thd user thread connection handle
509
@param session user thread connection handle
544
510
@param key databasename\\0tablename\\0
545
511
@param key_length length of key in bytes, including the NUL bytes
546
512
@param using_trx flag: TRUE if using transactions, FALSE otherwise
548
void mysql_query_cache_invalidate4(DRIZZLE_THD thd,
514
void mysql_query_cache_invalidate4(Session *session,
549
515
const char *key, unsigned int key_length,