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,
22
* it seems that the two files exist so that plugin.h can provide an
23
* external API for plugin developers and sql_plugin.h will provide
24
* and internal server API for dealing with those plugins.
26
* However, there are parts of plugin.h marked "INTERNAL USE ONLY" which
27
* seems to contradict the above...
29
* Let's figure out a better way of dividing the public and internal API
30
* and name the files more appropriately.
32
* Also, less #defines, more enums and bitmaps...
36
#ifndef DRIZZLE_SERVER_PLUGIN_H
37
#define DRIZZLE_SERVER_PLUGIN_H
42
the following flags are valid for plugin_init()
44
#define PLUGIN_INIT_SKIP_DYNAMIC_LOADING 1
45
#define PLUGIN_INIT_SKIP_PLUGIN_TABLE 2
46
#define PLUGIN_INIT_SKIP_INITIALIZATION 4
48
#define INITIAL_LEX_PLUGIN_LIST_SIZE 16
51
the following #define adds server-only members to enum_mysql_show_type,
52
that is defined in plugin.h
54
#define SHOW_FUNC SHOW_FUNC, SHOW_KEY_CACHE_LONG, SHOW_KEY_CACHE_LONGLONG, \
55
SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, SHOW_HAVE, \
56
SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, SHOW_LONG_NOFLUSH, \
58
#include <drizzled/plugin.h>
60
typedef enum enum_mysql_show_type SHOW_TYPE;
61
typedef struct st_mysql_show_var SHOW_VAR;
63
#define DRIZZLE_ANY_PLUGIN -1
66
different values of st_plugin_int::state
67
though they look like a bitmap, plugin may only
68
be in one of those eigenstates, not in a superposition of them :)
69
It's a bitmap, because it makes it easier to test
70
"whether the state is one of those..."
72
#define PLUGIN_IS_FREED 1
73
#define PLUGIN_IS_DELETED 2
74
#define PLUGIN_IS_UNINITIALIZED 4
75
#define PLUGIN_IS_READY 8
76
#define PLUGIN_IS_DYING 16
78
/* A handle for the dynamic library containing a plugin or plugins. */
84
struct st_mysql_plugin *plugins;
85
uint32_t ref_count; /* number of plugins loaded from the library */
88
/* A handle of a plugin */
93
struct st_mysql_plugin *plugin;
94
struct st_plugin_dl *plugin_dl;
96
uint32_t ref_count; /* number of threads using the plugin */
97
void *data; /* plugin type specific, e.g. handlerton */
98
MEM_ROOT mem_root; /* memory for dynamic plugin structures */
99
sys_var *system_vars; /* server variables for this plugin */
104
See intern_plugin_lock() for the explanation for the
105
conditionally defined plugin_ref type
107
typedef struct st_plugin_int **plugin_ref;
108
#define plugin_decl(pi) ((pi)[0]->plugin)
109
#define plugin_dlib(pi) ((pi)[0]->plugin_dl)
110
#define plugin_data(pi,cast) ((cast)((pi)[0]->data))
111
#define plugin_name(pi) (&((pi)[0]->name))
112
#define plugin_state(pi) ((pi)[0]->state)
113
#define plugin_equals(p1,p2) ((p1) && (p2) && (p1)[0] == (p2)[0])
115
typedef int (*plugin_type_init)(struct st_plugin_int *);
117
extern char *opt_plugin_load;
118
extern char *opt_plugin_dir_ptr;
119
extern char opt_plugin_dir[FN_REFLEN];
120
extern const LEX_STRING plugin_type_names[];
122
extern int plugin_init(int *argc, char **argv, int init_flags);
123
extern void plugin_shutdown(void);
124
extern void my_print_help_inc_plugins(struct my_option *options, uint32_t size);
125
extern bool plugin_is_ready(const LEX_STRING *name, int type);
126
#define my_plugin_lock_by_name(A,B,C) plugin_lock_by_name(A,B,C CALLER_INFO)
127
#define my_plugin_lock_by_name_ci(A,B,C) plugin_lock_by_name(A,B,C ORIG_CALLER_INFO)
128
#define my_plugin_lock(A,B) plugin_lock(A,B CALLER_INFO)
129
#define my_plugin_lock_ci(A,B) plugin_lock(A,B ORIG_CALLER_INFO)
130
extern plugin_ref plugin_lock(Session *session, plugin_ref *ptr CALLER_INFO_PROTO);
131
extern plugin_ref plugin_lock_by_name(Session *session, const LEX_STRING *name,
132
int type CALLER_INFO_PROTO);
133
extern void plugin_unlock(Session *session, plugin_ref plugin);
134
extern void plugin_unlock_list(Session *session, plugin_ref *list, uint32_t count);
135
extern bool mysql_install_plugin(Session *session, const LEX_STRING *name,
136
const LEX_STRING *dl);
137
extern bool mysql_uninstall_plugin(Session *session, const LEX_STRING *name);
138
extern bool plugin_register_builtin(struct st_mysql_plugin *plugin);
139
extern void plugin_sessionvar_init(Session *session);
140
extern void plugin_sessionvar_cleanup(Session *session);
142
typedef bool (plugin_foreach_func)(Session *session,
145
#define plugin_foreach(A,B,C,D) plugin_foreach_with_mask(A,B,C,PLUGIN_IS_READY,D)
146
extern bool plugin_foreach_with_mask(Session *session, plugin_foreach_func *func,
147
int type, uint32_t state_mask, void *arg);
148
#endif /* DRIZZLE_SERVER_PLUGIN_H */