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 */
17
* @TODO There is plugin.h and also sql_plugin.h. Ostensibly,
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
21
* @TODO There is plugin.h and also sql_plugin.h. Ostensibly,
18
22
* it seems that the two files exist so that plugin.h can provide an
19
23
* external API for plugin developers and sql_plugin.h will provide
20
24
* and internal server API for dealing with those plugins.
32
36
#ifndef DRIZZLE_SERVER_PLUGIN_H
33
37
#define DRIZZLE_SERVER_PLUGIN_H
39
#include <drizzled/lex_string.h>
40
#include <mysys/my_alloc.h>
41
#include <drizzled/plugin_registry.h>
42
#include <drizzled/plugin.h>
38
the following flags are valid for plugin_init()
40
#define PLUGIN_INIT_SKIP_DYNAMIC_LOADING 1
41
#define PLUGIN_INIT_SKIP_PLUGIN_TABLE 2
42
#define PLUGIN_INIT_SKIP_INITIALIZATION 4
44
#define INITIAL_LEX_PLUGIN_LIST_SIZE 16
47
the following #define adds server-only members to enum_mysql_show_type,
48
that is defined in plugin.h
50
#define SHOW_FUNC SHOW_FUNC, SHOW_KEY_CACHE_LONG, SHOW_KEY_CACHE_LONGLONG, \
51
SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, SHOW_HAVE, \
52
SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, SHOW_LONG_NOFLUSH, \
54
#include <drizzled/plugin.h>
56
typedef enum enum_mysql_show_type SHOW_TYPE;
57
typedef struct st_mysql_show_var SHOW_VAR;
59
#define DRIZZLE_ANY_PLUGIN -1
62
different values of st_plugin_int::state
63
though they look like a bitmap, plugin may only
64
be in one of those eigenstates, not in a superposition of them :)
65
It's a bitmap, because it makes it easier to test
66
"whether the state is one of those..."
68
#define PLUGIN_IS_FREED 1
69
#define PLUGIN_IS_DELETED 2
70
#define PLUGIN_IS_UNINITIALIZED 4
71
#define PLUGIN_IS_READY 8
72
#define PLUGIN_IS_DYING 16
74
48
/* A handle for the dynamic library containing a plugin or plugins. */
49
struct drizzled_plugin_manifest;
76
51
struct st_plugin_dl
80
struct st_mysql_plugin *plugins;
81
uint ref_count; /* number of plugins loaded from the library */
55
struct drizzled_plugin_manifest *plugins;
84
58
/* A handle of a plugin */
86
60
struct st_plugin_int
89
struct st_mysql_plugin *plugin;
63
struct drizzled_plugin_manifest *plugin;
90
64
struct st_plugin_dl *plugin_dl;
92
uint ref_count; /* number of threads using the plugin */
93
void *data; /* plugin type specific, e.g. handlerton */
94
66
MEM_ROOT mem_root; /* memory for dynamic plugin structures */
95
67
sys_var *system_vars; /* server variables for this plugin */
71
#define plugin_decl(pi) ((pi)->plugin)
72
#define plugin_data(pi,cast) (static_cast<cast>((pi)->data))
73
#define plugin_name(pi) (&((pi)->name))
74
#define plugin_equals(p1,p2) ((p1) && (p2) && (p1) == (p2))
77
typedef int (*plugin_type_init)(PluginRegistry &);
100
See intern_plugin_lock() for the explanation for the
101
conditionally defined plugin_ref type
80
Plugin description structure.
103
typedef struct st_plugin_int **plugin_ref;
104
#define plugin_decl(pi) ((pi)[0]->plugin)
105
#define plugin_dlib(pi) ((pi)[0]->plugin_dl)
106
#define plugin_data(pi,cast) ((cast)((pi)[0]->data))
107
#define plugin_name(pi) (&((pi)[0]->name))
108
#define plugin_state(pi) ((pi)[0]->state)
109
#define plugin_equals(p1,p2) ((p1) && (p2) && (p1)[0] == (p2)[0])
111
typedef int (*plugin_type_init)(struct st_plugin_int *);
83
struct drizzled_plugin_manifest
85
const char *name; /* plugin name (for SHOW PLUGINS) */
86
const char *version; /* plugin version (for SHOW PLUGINS) */
87
const char *author; /* plugin author (for SHOW PLUGINS) */
88
const char *descr; /* general descriptive text (for SHOW PLUGINS ) */
89
int license; /* plugin license (PLUGIN_LICENSE_XXX) */
90
plugin_type_init init; /* function to invoke when plugin is loaded */
91
plugin_type_init deinit; /* function to invoke when plugin is unloaded */
92
struct st_mysql_show_var *status_vars;
93
struct st_mysql_sys_var **system_vars;
94
void *reserved1; /* reserved for dependency checking */
113
97
extern char *opt_plugin_load;
114
98
extern char *opt_plugin_dir_ptr;
115
99
extern char opt_plugin_dir[FN_REFLEN];
116
extern const LEX_STRING plugin_type_names[];
118
101
extern int plugin_init(int *argc, char **argv, int init_flags);
119
102
extern void plugin_shutdown(void);
120
extern void my_print_help_inc_plugins(struct my_option *options, uint size);
103
extern void my_print_help_inc_plugins(struct my_option *options, uint32_t size);
121
104
extern bool plugin_is_ready(const LEX_STRING *name, int type);
122
#define my_plugin_lock_by_name(A,B,C) plugin_lock_by_name(A,B,C CALLER_INFO)
123
#define my_plugin_lock_by_name_ci(A,B,C) plugin_lock_by_name(A,B,C ORIG_CALLER_INFO)
124
#define my_plugin_lock(A,B) plugin_lock(A,B CALLER_INFO)
125
#define my_plugin_lock_ci(A,B) plugin_lock(A,B ORIG_CALLER_INFO)
126
extern plugin_ref plugin_lock(THD *thd, plugin_ref *ptr CALLER_INFO_PROTO);
127
extern plugin_ref plugin_lock_by_name(THD *thd, const LEX_STRING *name,
128
int type CALLER_INFO_PROTO);
129
extern void plugin_unlock(THD *thd, plugin_ref plugin);
130
extern void plugin_unlock_list(THD *thd, plugin_ref *list, uint count);
131
extern bool mysql_install_plugin(THD *thd, const LEX_STRING *name,
105
extern bool mysql_install_plugin(Session *session, const LEX_STRING *name,
132
106
const LEX_STRING *dl);
133
extern bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name);
134
extern bool plugin_register_builtin(struct st_mysql_plugin *plugin);
135
extern void plugin_thdvar_init(THD *thd);
136
extern void plugin_thdvar_cleanup(THD *thd);
107
extern bool mysql_uninstall_plugin(Session *session, const LEX_STRING *name);
108
extern bool plugin_register_builtin(struct drizzled_plugin_manifest *plugin);
109
extern void plugin_sessionvar_init(Session *session);
110
extern void plugin_sessionvar_cleanup(Session *session);
111
extern sys_var *intern_find_sys_var(const char *str, uint32_t, bool no_error);
138
typedef bool (plugin_foreach_func)(THD *thd,
141
#define plugin_foreach(A,B,C,D) plugin_foreach_with_mask(A,B,C,PLUGIN_IS_READY,D)
142
extern bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
143
int type, uint state_mask, void *arg);
144
113
#endif /* DRIZZLE_SERVER_PLUGIN_H */