2 Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; version 2 of the License.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 the following flags are valid for plugin_init()
26 #define PLUGIN_INIT_SKIP_DYNAMIC_LOADING 1
27 #define PLUGIN_INIT_SKIP_PLUGIN_TABLE 2
28 #define PLUGIN_INIT_SKIP_INITIALIZATION 4
30 #define INITIAL_LEX_PLUGIN_LIST_SIZE 16
33 the following #define adds server-only members to enum_mysql_show_type,
34 that is defined in plugin.h
36 #define SHOW_FUNC SHOW_FUNC, SHOW_KEY_CACHE_LONG, SHOW_KEY_CACHE_LONGLONG, \
37 SHOW_LONG_STATUS, SHOW_DOUBLE_STATUS, SHOW_HAVE, \
38 SHOW_MY_BOOL, SHOW_HA_ROWS, SHOW_SYS, SHOW_LONG_NOFLUSH, \
40 #include <mysql/plugin.h>
42 typedef enum enum_mysql_show_type SHOW_TYPE
;
43 typedef struct st_mysql_show_var SHOW_VAR
;
45 #define MYSQL_ANY_PLUGIN -1
48 different values of st_plugin_int::state
49 though they look like a bitmap, plugin may only
50 be in one of those eigenstates, not in a superposition of them :)
51 It's a bitmap, because it makes it easier to test
52 "whether the state is one of those..."
54 #define PLUGIN_IS_FREED 1
55 #define PLUGIN_IS_DELETED 2
56 #define PLUGIN_IS_UNINITIALIZED 4
57 #define PLUGIN_IS_READY 8
58 #define PLUGIN_IS_DYING 16
59 #define PLUGIN_IS_DISABLED 32
61 /* A handle for the dynamic library containing a plugin or plugins. */
67 struct st_mysql_plugin
*plugins
;
69 uint ref_count
; /* number of plugins loaded from the library */
72 /* A handle of a plugin */
77 struct st_mysql_plugin
*plugin
;
78 struct st_plugin_dl
*plugin_dl
;
80 uint ref_count
; /* number of threads using the plugin */
81 void *data
; /* plugin type specific, e.g. handlerton */
82 MEM_ROOT mem_root
; /* memory for dynamic plugin structures */
83 sys_var
*system_vars
; /* server variables for this plugin */
84 bool is_mandatory
; /* If true then plugin must not fail to load */
89 See intern_plugin_lock() for the explanation for the
90 conditionally defined plugin_ref type
93 typedef struct st_plugin_int
*plugin_ref
;
94 #define plugin_decl(pi) ((pi)->plugin)
95 #define plugin_dlib(pi) ((pi)->plugin_dl)
96 #define plugin_data(pi,cast) ((cast)((pi)->data))
97 #define plugin_name(pi) (&((pi)->name))
98 #define plugin_state(pi) ((pi)->state)
99 #define plugin_equals(p1,p2) ((p1) == (p2))
101 typedef struct st_plugin_int
**plugin_ref
;
102 #define plugin_decl(pi) ((pi)[0]->plugin)
103 #define plugin_dlib(pi) ((pi)[0]->plugin_dl)
104 #define plugin_data(pi,cast) ((cast)((pi)[0]->data))
105 #define plugin_name(pi) (&((pi)[0]->name))
106 #define plugin_state(pi) ((pi)[0]->state)
107 #define plugin_equals(p1,p2) ((p1) && (p2) && (p1)[0] == (p2)[0])
110 typedef int (*plugin_type_init
)(struct st_plugin_int
*);
112 extern char *opt_plugin_load
;
113 extern char *opt_plugin_dir_ptr
;
114 extern char opt_plugin_dir
[FN_REFLEN
];
115 extern const LEX_STRING plugin_type_names
[];
117 extern int plugin_init(int *argc
, char **argv
, int init_flags
);
118 extern void plugin_shutdown(void);
119 extern void my_print_help_inc_plugins(struct my_option
*options
, uint size
);
120 extern bool plugin_is_ready(const LEX_STRING
*name
, int type
);
121 #define my_plugin_lock_by_name(A,B,C) plugin_lock_by_name(A,B,C CALLER_INFO)
122 #define my_plugin_lock_by_name_ci(A,B,C) plugin_lock_by_name(A,B,C ORIG_CALLER_INFO)
123 #define my_plugin_lock(A,B) plugin_lock(A,B CALLER_INFO)
124 #define my_plugin_lock_ci(A,B) plugin_lock(A,B ORIG_CALLER_INFO)
125 extern plugin_ref
plugin_lock(THD
*thd
, plugin_ref
*ptr CALLER_INFO_PROTO
);
126 extern plugin_ref
plugin_lock_by_name(THD
*thd
, const LEX_STRING
*name
,
127 int type CALLER_INFO_PROTO
);
128 extern void plugin_unlock(THD
*thd
, plugin_ref plugin
);
129 extern void plugin_unlock_list(THD
*thd
, plugin_ref
*list
, uint count
);
130 extern bool mysql_install_plugin(THD
*thd
, const LEX_STRING
*name
,
131 const LEX_STRING
*dl
);
132 extern bool mysql_uninstall_plugin(THD
*thd
, const LEX_STRING
*name
);
133 extern bool plugin_register_builtin(struct st_mysql_plugin
*plugin
);
134 extern void plugin_thdvar_init(THD
*thd
);
135 extern void plugin_thdvar_cleanup(THD
*thd
);
136 extern bool check_valid_path(const char *path
, size_t length
);
138 typedef my_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
);