1
by brian
clean slate |
1 |
/* Copyright (C) 2005 MySQL AB
|
2 |
||
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.
|
|
6 |
||
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.
|
|
11 |
||
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 */
|
|
15 |
||
243.1.11
by Jay Pipes
* Added include guards in a couple places, and removed unecessary |
16 |
/**
|
17 |
* @TODO There is plugin.h and also sql_plugin.h. Ostensibly,
|
|
18 |
* it seems that the two files exist so that plugin.h can provide an
|
|
19 |
* external API for plugin developers and sql_plugin.h will provide
|
|
20 |
* and internal server API for dealing with those plugins.
|
|
21 |
*
|
|
22 |
* However, there are parts of plugin.h marked "INTERNAL USE ONLY" which
|
|
23 |
* seems to contradict the above...
|
|
24 |
*
|
|
25 |
* Let's figure out a better way of dividing the public and internal API
|
|
26 |
* and name the files more appropriately.
|
|
27 |
*
|
|
28 |
* Also, less #defines, more enums and bitmaps...
|
|
29 |
*
|
|
30 |
*/
|
|
31 |
||
32 |
#ifndef DRIZZLE_SERVER_PLUGIN_H
|
|
33 |
#define DRIZZLE_SERVER_PLUGIN_H
|
|
1
by brian
clean slate |
34 |
|
35 |
class sys_var; |
|
36 |
||
37 |
/*
|
|
38 |
the following flags are valid for plugin_init()
|
|
39 |
*/
|
|
40 |
#define PLUGIN_INIT_SKIP_DYNAMIC_LOADING 1
|
|
41 |
#define PLUGIN_INIT_SKIP_PLUGIN_TABLE 2
|
|
42 |
#define PLUGIN_INIT_SKIP_INITIALIZATION 4
|
|
43 |
||
44 |
#define INITIAL_LEX_PLUGIN_LIST_SIZE 16
|
|
45 |
||
46 |
/*
|
|
47 |
the following #define adds server-only members to enum_mysql_show_type,
|
|
48 |
that is defined in plugin.h
|
|
49 |
*/
|
|
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, \
|
|
53 |
SHOW_LONGLONG_STATUS
|
|
212.5.10
by Monty Taylor
Moved drizzle/plugin*h to drizzled |
54 |
#include <drizzled/plugin.h> |
1
by brian
clean slate |
55 |
#undef SHOW_FUNC
|
56 |
typedef enum enum_mysql_show_type SHOW_TYPE; |
|
57 |
typedef struct st_mysql_show_var SHOW_VAR; |
|
58 |
||
59 |
#define MYSQL_ANY_PLUGIN -1
|
|
60 |
||
61 |
/*
|
|
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..."
|
|
67 |
*/
|
|
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
|
|
73 |
||
74 |
/* A handle for the dynamic library containing a plugin or plugins. */
|
|
75 |
||
76 |
struct st_plugin_dl |
|
77 |
{
|
|
78 |
LEX_STRING dl; |
|
79 |
void *handle; |
|
80 |
struct st_mysql_plugin *plugins; |
|
81 |
uint ref_count; /* number of plugins loaded from the library */ |
|
82 |
};
|
|
83 |
||
84 |
/* A handle of a plugin */
|
|
85 |
||
86 |
struct st_plugin_int |
|
87 |
{
|
|
88 |
LEX_STRING name; |
|
89 |
struct st_mysql_plugin *plugin; |
|
90 |
struct st_plugin_dl *plugin_dl; |
|
91 |
uint state; |
|
92 |
uint ref_count; /* number of threads using the plugin */ |
|
93 |
void *data; /* plugin type specific, e.g. handlerton */ |
|
94 |
MEM_ROOT mem_root; /* memory for dynamic plugin structures */ |
|
95 |
sys_var *system_vars; /* server variables for this plugin */ |
|
96 |
};
|
|
97 |
||
98 |
||
99 |
/*
|
|
100 |
See intern_plugin_lock() for the explanation for the
|
|
101 |
conditionally defined plugin_ref type
|
|
102 |
*/
|
|
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])
|
|
110 |
||
111 |
typedef int (*plugin_type_init)(struct st_plugin_int *); |
|
112 |
||
113 |
extern char *opt_plugin_load; |
|
114 |
extern char *opt_plugin_dir_ptr; |
|
115 |
extern char opt_plugin_dir[FN_REFLEN]; |
|
116 |
extern const LEX_STRING plugin_type_names[]; |
|
117 |
||
118 |
extern int plugin_init(int *argc, char **argv, int init_flags); |
|
119 |
extern void plugin_shutdown(void); |
|
120 |
extern void my_print_help_inc_plugins(struct my_option *options, uint size); |
|
121 |
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, |
|
132 |
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); |
|
137 |
||
149
by Brian Aker
More bool conversion. |
138 |
typedef bool (plugin_foreach_func)(THD *thd, |
139 |
plugin_ref plugin, |
|
140 |
void *arg); |
|
1
by brian
clean slate |
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); |
|
243.1.11
by Jay Pipes
* Added include guards in a couple places, and removed unecessary |
144 |
#endif /* DRIZZLE_SERVER_PLUGIN_H */ |