1
/* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
19
#include <my_global.h>
22
the following #define adds server-only members to enum_mysql_show_type,
23
that is defined in plugin.h
25
#define SHOW_always_last SHOW_KEY_CACHE_LONG, \
26
SHOW_KEY_CACHE_LONGLONG, SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, \
27
SHOW_HAVE, SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, \
28
SHOW_LONG_NOFLUSH, SHOW_LONGLONG_STATUS, SHOW_LEX_STRING
29
#include <mysql/plugin.h>
30
#undef SHOW_always_last
32
#include "m_string.h" /* LEX_STRING */
33
#include "my_alloc.h" /* MEM_ROOT */
36
enum SHOW_COMP_OPTION { SHOW_OPTION_YES, SHOW_OPTION_NO, SHOW_OPTION_DISABLED};
37
enum enum_plugin_load_option { PLUGIN_OFF, PLUGIN_ON, PLUGIN_FORCE,
38
PLUGIN_FORCE_PLUS_PERMANENT };
39
extern const char *global_plugin_typelib_names[];
44
#define plugin_ref_to_int(A) A
45
#define plugin_int_to_ref(A) A
47
#define plugin_ref_to_int(A) (A ? A[0] : NULL)
48
#define plugin_int_to_ref(A) &(A)
52
the following flags are valid for plugin_init()
54
#define PLUGIN_INIT_SKIP_DYNAMIC_LOADING 1
55
#define PLUGIN_INIT_SKIP_PLUGIN_TABLE 2
56
#define PLUGIN_INIT_SKIP_INITIALIZATION 4
58
#define INITIAL_LEX_PLUGIN_LIST_SIZE 16
60
typedef enum enum_mysql_show_type SHOW_TYPE;
61
typedef struct st_mysql_show_var SHOW_VAR;
62
typedef struct st_mysql_lex_string LEX_STRING;
64
#define MYSQL_ANY_PLUGIN -1
67
different values of st_plugin_int::state
68
though they look like a bitmap, plugin may only
69
be in one of those eigenstates, not in a superposition of them :)
70
It's a bitmap, because it makes it easier to test
71
"whether the state is one of those..."
73
#define PLUGIN_IS_FREED 1
74
#define PLUGIN_IS_DELETED 2
75
#define PLUGIN_IS_UNINITIALIZED 4
76
#define PLUGIN_IS_READY 8
77
#define PLUGIN_IS_DYING 16
78
#define PLUGIN_IS_DISABLED 32
80
/* A handle for the dynamic library containing a plugin or plugins. */
86
struct st_mysql_plugin *plugins;
88
uint ref_count; /* number of plugins loaded from the library */
91
/* A handle of a plugin */
96
struct st_mysql_plugin *plugin;
97
struct st_plugin_dl *plugin_dl;
99
uint ref_count; /* number of threads using the plugin */
100
void *data; /* plugin type specific, e.g. handlerton */
101
MEM_ROOT mem_root; /* memory for dynamic plugin structures */
102
sys_var *system_vars; /* server variables for this plugin */
103
enum enum_plugin_load_option load_option; /* OFF, ON, FORCE, F+PERMANENT */
108
See intern_plugin_lock() for the explanation for the
109
conditionally defined plugin_ref type
112
typedef struct st_plugin_int *plugin_ref;
113
#define plugin_decl(pi) ((pi)->plugin)
114
#define plugin_dlib(pi) ((pi)->plugin_dl)
115
#define plugin_data(pi,cast) ((cast)((pi)->data))
116
#define plugin_name(pi) (&((pi)->name))
117
#define plugin_state(pi) ((pi)->state)
118
#define plugin_load_option(pi) ((pi)->load_option)
119
#define plugin_equals(p1,p2) ((p1) == (p2))
121
typedef struct st_plugin_int **plugin_ref;
122
#define plugin_decl(pi) ((pi)[0]->plugin)
123
#define plugin_dlib(pi) ((pi)[0]->plugin_dl)
124
#define plugin_data(pi,cast) ((cast)((pi)[0]->data))
125
#define plugin_name(pi) (&((pi)[0]->name))
126
#define plugin_state(pi) ((pi)[0]->state)
127
#define plugin_load_option(pi) ((pi)[0]->load_option)
128
#define plugin_equals(p1,p2) ((p1) && (p2) && (p1)[0] == (p2)[0])
131
typedef int (*plugin_type_init)(struct st_plugin_int *);
133
extern char *opt_plugin_load;
134
extern char *opt_plugin_dir_ptr;
135
extern char opt_plugin_dir[FN_REFLEN];
136
extern const LEX_STRING plugin_type_names[];
138
extern int plugin_init(int *argc, char **argv, int init_flags);
139
extern void plugin_shutdown(void);
140
void add_plugin_options(DYNAMIC_ARRAY *options, MEM_ROOT *mem_root);
141
extern bool plugin_is_ready(const LEX_STRING *name, int type);
142
#define my_plugin_lock_by_name(A,B,C) plugin_lock_by_name(A,B,C)
143
#define my_plugin_lock_by_name_ci(A,B,C) plugin_lock_by_name(A,B,C)
144
#define my_plugin_lock(A,B) plugin_lock(A,B)
145
#define my_plugin_lock_ci(A,B) plugin_lock(A,B)
146
extern plugin_ref plugin_lock(THD *thd, plugin_ref *ptr);
147
extern plugin_ref plugin_lock_by_name(THD *thd, const LEX_STRING *name,
149
extern void plugin_unlock(THD *thd, plugin_ref plugin);
150
extern void plugin_unlock_list(THD *thd, plugin_ref *list, uint count);
151
extern bool mysql_install_plugin(THD *thd, const LEX_STRING *name,
152
const LEX_STRING *dl);
153
extern bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name);
154
extern bool plugin_register_builtin(struct st_mysql_plugin *plugin);
155
extern void plugin_thdvar_init(THD *thd);
156
extern void plugin_thdvar_cleanup(THD *thd);
157
extern SHOW_COMP_OPTION plugin_status(const char *name, int len, size_t type);
158
extern bool check_valid_path(const char *path, size_t length);
160
typedef my_bool (plugin_foreach_func)(THD *thd,
163
#define plugin_foreach(A,B,C,D) plugin_foreach_with_mask(A,B,C,PLUGIN_IS_READY,D)
164
extern bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
165
int type, uint state_mask, void *arg);