390.1.2
by Monty Taylor
Fixed copyright headers in drizzled/ |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
4 |
* Copyright (C) 2008 Sun Microsystems
|
|
5 |
*
|
|
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.
|
|
9 |
*
|
|
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.
|
|
14 |
*
|
|
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
|
|
18 |
*/
|
|
1
by brian
clean slate |
19 |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
20 |
/**
|
21 |
* @TODO There is plugin.h and also sql_plugin.h. Ostensibly,
|
|
243.1.11
by Jay Pipes
* Added include guards in a couple places, and removed unecessary |
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.
|
|
25 |
*
|
|
26 |
* However, there are parts of plugin.h marked "INTERNAL USE ONLY" which
|
|
27 |
* seems to contradict the above...
|
|
28 |
*
|
|
29 |
* Let's figure out a better way of dividing the public and internal API
|
|
30 |
* and name the files more appropriately.
|
|
31 |
*
|
|
32 |
* Also, less #defines, more enums and bitmaps...
|
|
33 |
*
|
|
34 |
*/
|
|
35 |
||
36 |
#ifndef DRIZZLE_SERVER_PLUGIN_H
|
|
37 |
#define DRIZZLE_SERVER_PLUGIN_H
|
|
1
by brian
clean slate |
38 |
|
575.1.6
by Monty Taylor
Cleaned up some headers for PCH. |
39 |
#include <drizzled/lex_string.h> |
40 |
#include <mysys/my_alloc.h> |
|
41 |
||
1
by brian
clean slate |
42 |
class sys_var; |
575.1.6
by Monty Taylor
Cleaned up some headers for PCH. |
43 |
class Session; |
1
by brian
clean slate |
44 |
|
45 |
/*
|
|
46 |
the following flags are valid for plugin_init()
|
|
47 |
*/
|
|
48 |
#define PLUGIN_INIT_SKIP_DYNAMIC_LOADING 1
|
|
49 |
#define PLUGIN_INIT_SKIP_PLUGIN_TABLE 2
|
|
50 |
#define PLUGIN_INIT_SKIP_INITIALIZATION 4
|
|
51 |
||
52 |
#define INITIAL_LEX_PLUGIN_LIST_SIZE 16
|
|
53 |
||
54 |
/*
|
|
55 |
the following #define adds server-only members to enum_mysql_show_type,
|
|
56 |
that is defined in plugin.h
|
|
57 |
*/
|
|
58 |
#define SHOW_FUNC SHOW_FUNC, SHOW_KEY_CACHE_LONG, SHOW_KEY_CACHE_LONGLONG, \
|
|
59 |
SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, SHOW_HAVE, \
|
|
60 |
SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, SHOW_LONG_NOFLUSH, \
|
|
61 |
SHOW_LONGLONG_STATUS
|
|
212.5.10
by Monty Taylor
Moved drizzle/plugin*h to drizzled |
62 |
#include <drizzled/plugin.h> |
1
by brian
clean slate |
63 |
#undef SHOW_FUNC
|
64 |
typedef enum enum_mysql_show_type SHOW_TYPE; |
|
65 |
typedef struct st_mysql_show_var SHOW_VAR; |
|
66 |
||
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
67 |
#define DRIZZLE_ANY_PLUGIN -1
|
1
by brian
clean slate |
68 |
|
69 |
/*
|
|
70 |
different values of st_plugin_int::state
|
|
71 |
though they look like a bitmap, plugin may only
|
|
72 |
be in one of those eigenstates, not in a superposition of them :)
|
|
73 |
It's a bitmap, because it makes it easier to test
|
|
74 |
"whether the state is one of those..."
|
|
75 |
*/
|
|
76 |
#define PLUGIN_IS_FREED 1
|
|
77 |
#define PLUGIN_IS_DELETED 2
|
|
78 |
#define PLUGIN_IS_UNINITIALIZED 4
|
|
79 |
#define PLUGIN_IS_READY 8
|
|
80 |
#define PLUGIN_IS_DYING 16
|
|
81 |
||
82 |
/* A handle for the dynamic library containing a plugin or plugins. */
|
|
83 |
||
84 |
struct st_plugin_dl |
|
85 |
{
|
|
86 |
LEX_STRING dl; |
|
87 |
void *handle; |
|
88 |
struct st_mysql_plugin *plugins; |
|
482
by Brian Aker
Remove uint. |
89 |
uint32_t ref_count; /* number of plugins loaded from the library */ |
1
by brian
clean slate |
90 |
};
|
91 |
||
92 |
/* A handle of a plugin */
|
|
93 |
||
94 |
struct st_plugin_int |
|
95 |
{
|
|
96 |
LEX_STRING name; |
|
97 |
struct st_mysql_plugin *plugin; |
|
98 |
struct st_plugin_dl *plugin_dl; |
|
482
by Brian Aker
Remove uint. |
99 |
uint32_t state; |
100 |
uint32_t ref_count; /* number of threads using the plugin */ |
|
1
by brian
clean slate |
101 |
void *data; /* plugin type specific, e.g. handlerton */ |
102 |
MEM_ROOT mem_root; /* memory for dynamic plugin structures */ |
|
103 |
sys_var *system_vars; /* server variables for this plugin */ |
|
104 |
};
|
|
105 |
||
106 |
||
107 |
/*
|
|
108 |
See intern_plugin_lock() for the explanation for the
|
|
109 |
conditionally defined plugin_ref type
|
|
110 |
*/
|
|
111 |
typedef struct st_plugin_int **plugin_ref; |
|
112 |
#define plugin_decl(pi) ((pi)[0]->plugin)
|
|
113 |
#define plugin_dlib(pi) ((pi)[0]->plugin_dl)
|
|
114 |
#define plugin_data(pi,cast) ((cast)((pi)[0]->data))
|
|
115 |
#define plugin_name(pi) (&((pi)[0]->name))
|
|
116 |
#define plugin_state(pi) ((pi)[0]->state)
|
|
117 |
#define plugin_equals(p1,p2) ((p1) && (p2) && (p1)[0] == (p2)[0])
|
|
118 |
||
119 |
typedef int (*plugin_type_init)(struct st_plugin_int *); |
|
120 |
||
121 |
extern char *opt_plugin_load; |
|
122 |
extern char *opt_plugin_dir_ptr; |
|
123 |
extern char opt_plugin_dir[FN_REFLEN]; |
|
124 |
extern const LEX_STRING plugin_type_names[]; |
|
125 |
||
126 |
extern int plugin_init(int *argc, char **argv, int init_flags); |
|
127 |
extern void plugin_shutdown(void); |
|
482
by Brian Aker
Remove uint. |
128 |
extern void my_print_help_inc_plugins(struct my_option *options, uint32_t size); |
1
by brian
clean slate |
129 |
extern bool plugin_is_ready(const LEX_STRING *name, int type); |
575.1.6
by Monty Taylor
Cleaned up some headers for PCH. |
130 |
#define my_plugin_lock_by_name(A,B,C) plugin_lock_by_name(A,B,C)
|
131 |
#define my_plugin_lock_by_name_ci(A,B,C) plugin_lock_by_name(A,B,C)
|
|
132 |
#define my_plugin_lock(A,B) plugin_lock(A,B)
|
|
133 |
#define my_plugin_lock_ci(A,B) plugin_lock(A,B)
|
|
134 |
extern plugin_ref plugin_lock(Session *session, plugin_ref *ptr); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
135 |
extern plugin_ref plugin_lock_by_name(Session *session, const LEX_STRING *name, |
575.1.6
by Monty Taylor
Cleaned up some headers for PCH. |
136 |
int type); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
137 |
extern void plugin_unlock(Session *session, plugin_ref plugin); |
138 |
extern void plugin_unlock_list(Session *session, plugin_ref *list, uint32_t count); |
|
139 |
extern bool mysql_install_plugin(Session *session, const LEX_STRING *name, |
|
1
by brian
clean slate |
140 |
const LEX_STRING *dl); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
141 |
extern bool mysql_uninstall_plugin(Session *session, const LEX_STRING *name); |
1
by brian
clean slate |
142 |
extern bool plugin_register_builtin(struct st_mysql_plugin *plugin); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
143 |
extern void plugin_sessionvar_init(Session *session); |
144 |
extern void plugin_sessionvar_cleanup(Session *session); |
|
1
by brian
clean slate |
145 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
146 |
typedef bool (plugin_foreach_func)(Session *session, |
149
by Brian Aker
More bool conversion. |
147 |
plugin_ref plugin, |
148 |
void *arg); |
|
1
by brian
clean slate |
149 |
#define plugin_foreach(A,B,C,D) plugin_foreach_with_mask(A,B,C,PLUGIN_IS_READY,D)
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
150 |
extern bool plugin_foreach_with_mask(Session *session, plugin_foreach_func *func, |
482
by Brian Aker
Remove uint. |
151 |
int type, uint32_t state_mask, void *arg); |
243.1.11
by Jay Pipes
* Added include guards in a couple places, and removed unecessary |
152 |
#endif /* DRIZZLE_SERVER_PLUGIN_H */ |