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.17
by Jay Pipes
FINAL PHASE removal of mysql_priv.h (Bye, bye my friend.) |
16 |
#include <drizzled/server_includes.h> |
212.5.21
by Monty Taylor
Moved my_getopt.h |
17 |
#include <mysys/my_getopt.h> |
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
18 |
#include <mysys/hash.h> |
499.2.9
by Mark Atwood
fix mistakes |
19 |
|
549
by Monty Taylor
Took gettext.h out of header files. |
20 |
#include <drizzled/authentication.h> |
21 |
#include <drizzled/logging.h> |
|
22 |
#include <drizzled/errmsg.h> |
|
23 |
#include <drizzled/qcache.h> |
|
520.8.2
by Monty Taylor
Moved sql_parse.h and sql_error.h out of common_includes. |
24 |
#include <drizzled/sql_parse.h> |
549
by Monty Taylor
Took gettext.h out of header files. |
25 |
#include <drizzled/scheduling.h> |
1039.5.31
by Jay Pipes
This patch does a few things: |
26 |
#include <drizzled/replication_services.h> |
575.4.7
by Monty Taylor
More header cleanup. |
27 |
#include <drizzled/show.h> |
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
28 |
#include <drizzled/handler.h> |
29 |
#include <drizzled/set_var.h> |
|
30 |
#include <drizzled/session.h> |
|
642.1.20
by Lee
header file clean up |
31 |
#include <drizzled/item/null.h> |
1110.1.5
by Monty Taylor
Renamed PluginRegistry to plugin::Registry. |
32 |
#include <drizzled/plugin/registry.h> |
1126.6.2
by Monty Taylor
Split plugin builtins defines into their own header to ease rebuild issues. |
33 |
#include "drizzled/plugin/config.h" |
499.2.9
by Mark Atwood
fix mistakes |
34 |
|
534
by Monty Taylor
Removed stxnmov. Also deleted strstr which had already been removed. |
35 |
#include <string> |
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
36 |
#include <vector> |
873.2.21
by Monty Taylor
Removed the HASH for plugin_hash. |
37 |
#include <map> |
1067.4.4
by Nathan Williams
The rest of the files in the drizzled directory were purged of the cmin macro and replace with std::min (except for the definition in globals.h and 1 usage in stacktrace.cc). |
38 |
#include <algorithm> |
534
by Monty Taylor
Removed stxnmov. Also deleted strstr which had already been removed. |
39 |
|
549
by Monty Taylor
Took gettext.h out of header files. |
40 |
#include <drizzled/error.h> |
41 |
#include <drizzled/gettext.h> |
|
499.2.7
by Mark Atwood
some bugs in errmsg plugin |
42 |
|
1
by brian
clean slate |
43 |
#define REPORT_TO_LOG 1
|
44 |
#define REPORT_TO_USER 2
|
|
45 |
||
534
by Monty Taylor
Removed stxnmov. Also deleted strstr which had already been removed. |
46 |
using namespace std; |
1093.3.1
by Monty Taylor
Rename of plugin classes. |
47 |
using namespace drizzled; |
992.1.39
by Monty Taylor
Removed the m4-based plugin system. |
48 |
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
49 |
typedef plugin::Manifest builtin_plugin[]; |
1093.9.13
by Monty Taylor
pandora-build v0.42 - Started splitting out plugin system into pandora-build |
50 |
extern builtin_plugin PANDORA_BUILTIN_LIST; |
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
51 |
static plugin::Manifest *drizzled_builtins[]= |
992.1.39
by Monty Taylor
Removed the m4-based plugin system. |
52 |
{
|
1115.3.8
by Jay Pipes
Merge and resolve conflicts on pandora build fixes. |
53 |
PANDORA_BUILTIN_LIST,(plugin::Manifest *)NULL |
992.1.39
by Monty Taylor
Removed the m4-based plugin system. |
54 |
};
|
1101.1.27
by Monty Taylor
Fixed the plugin string valgrind leak. |
55 |
class sys_var_pluginvar; |
56 |
static vector<sys_var_pluginvar *> plugin_sysvar_vec; |
|
1
by brian
clean slate |
57 |
|
58 |
char *opt_plugin_load= NULL; |
|
1093.9.13
by Monty Taylor
pandora-build v0.42 - Started splitting out plugin system into pandora-build |
59 |
const char *opt_plugin_load_default= QUOTE_ARG(PANDORA_PLUGIN_LIST); |
1
by brian
clean slate |
60 |
char *opt_plugin_dir_ptr; |
61 |
char opt_plugin_dir[FN_REFLEN]; |
|
1093.3.1
by Monty Taylor
Rename of plugin classes. |
62 |
static const char *plugin_declarations_sym= "_drizzled_plugin_declaration_"; |
1
by brian
clean slate |
63 |
|
64 |
/* Note that 'int version' must be the first field of every plugin
|
|
65 |
sub-structure (plugin->info).
|
|
66 |
*/
|
|
67 |
||
962.1.6
by Brian Aker
Cut down on shutdown loop of plugins (cutting stuff out in order to simplify |
68 |
static bool initialized= false; |
1
by brian
clean slate |
69 |
|
70 |
static DYNAMIC_ARRAY plugin_dl_array; |
|
71 |
static DYNAMIC_ARRAY plugin_array; |
|
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
72 |
|
1
by brian
clean slate |
73 |
static bool reap_needed= false; |
74 |
||
75 |
/*
|
|
76 |
write-lock on LOCK_system_variables_hash is required before modifying
|
|
77 |
the following variables/structures
|
|
78 |
*/
|
|
79 |
static MEM_ROOT plugin_mem_root; |
|
482
by Brian Aker
Remove uint. |
80 |
static uint32_t global_variables_dynamic_size= 0; |
1
by brian
clean slate |
81 |
static HASH bookmark_hash; |
82 |
||
83 |
||
84 |
/*
|
|
85 |
hidden part of opaque value passed to variable check functions.
|
|
86 |
Used to provide a object-like structure to non C++ consumers.
|
|
87 |
*/
|
|
88 |
struct st_item_value_holder : public st_mysql_value |
|
89 |
{
|
|
90 |
Item *item; |
|
91 |
};
|
|
92 |
||
93 |
||
94 |
/*
|
|
95 |
stored in bookmark_hash, this structure is never removed from the
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
96 |
hash and is used to mark a single offset for a session local variable
|
1
by brian
clean slate |
97 |
even if plugins have been uninstalled and reinstalled, repeatedly.
|
98 |
This structure is allocated from plugin_mem_root.
|
|
99 |
||
100 |
The key format is as follows:
|
|
101 |
1 byte - variable type code
|
|
102 |
name_len bytes - variable name
|
|
103 |
'\0' - end of key
|
|
104 |
*/
|
|
105 |
struct st_bookmark |
|
106 |
{
|
|
482
by Brian Aker
Remove uint. |
107 |
uint32_t name_len; |
1
by brian
clean slate |
108 |
int offset; |
482
by Brian Aker
Remove uint. |
109 |
uint32_t version; |
1
by brian
clean slate |
110 |
char key[1]; |
111 |
};
|
|
112 |
||
113 |
||
114 |
/*
|
|
115 |
skeleton of a plugin variable - portion of structure common to all.
|
|
116 |
*/
|
|
117 |
struct st_mysql_sys_var |
|
118 |
{
|
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
119 |
DRIZZLE_PLUGIN_VAR_HEADER; |
1
by brian
clean slate |
120 |
};
|
121 |
||
122 |
||
123 |
/*
|
|
124 |
sys_var class for access to all plugin variables visible to the user
|
|
125 |
*/
|
|
126 |
class sys_var_pluginvar: public sys_var |
|
127 |
{
|
|
128 |
public: |
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
129 |
plugin::Handle *plugin; |
1
by brian
clean slate |
130 |
struct st_mysql_sys_var *plugin_var; |
131 |
||
1101.1.27
by Monty Taylor
Fixed the plugin string valgrind leak. |
132 |
sys_var_pluginvar(const std::string name_arg, |
1
by brian
clean slate |
133 |
struct st_mysql_sys_var *plugin_var_arg) |
134 |
:sys_var(name_arg), plugin_var(plugin_var_arg) {} |
|
135 |
sys_var_pluginvar *cast_pluginvar() { return this; } |
|
136 |
bool is_readonly() const { return plugin_var->flags & PLUGIN_VAR_READONLY; } |
|
137 |
bool check_type(enum_var_type type) |
|
520.1.21
by Brian Aker
THD -> Session rename |
138 |
{ return !(plugin_var->flags & PLUGIN_VAR_SessionLOCAL) && type != OPT_GLOBAL; } |
1
by brian
clean slate |
139 |
bool check_update_type(Item_result type); |
140 |
SHOW_TYPE show_type(); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
141 |
unsigned char* real_value_ptr(Session *session, enum_var_type type); |
1
by brian
clean slate |
142 |
TYPELIB* plugin_var_typelib(void); |
779.3.10
by Monty Taylor
Turned on -Wshadow. |
143 |
unsigned char* value_ptr(Session *session, enum_var_type type, |
144 |
const LEX_STRING *base); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
145 |
bool check(Session *session, set_var *var); |
654
by Brian Aker
Remove unused (yet more) |
146 |
bool check_default(enum_var_type) |
77.1.46
by Monty Taylor
Finished the warnings work! |
147 |
{ return is_readonly(); } |
654
by Brian Aker
Remove unused (yet more) |
148 |
void set_default(Session *session, enum_var_type); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
149 |
bool update(Session *session, set_var *var); |
1
by brian
clean slate |
150 |
};
|
151 |
||
152 |
||
153 |
/* prototypes */
|
|
1110.1.5
by Monty Taylor
Renamed PluginRegistry to plugin::Registry. |
154 |
static bool plugin_load_list(plugin::Registry ®istry, |
1110.1.3
by Monty Taylor
Added ListenHandler as a member of PluginRegistry. |
155 |
MEM_ROOT *tmp_root, int *argc, char **argv, |
1
by brian
clean slate |
156 |
const char *list); |
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
157 |
static int test_plugin_options(MEM_ROOT *, plugin::Handle *, |
135
by Brian Aker
Random cleanup. Dead partition tests, pass operator in sql_plugin, mtr based |
158 |
int *, char **); |
1110.1.5
by Monty Taylor
Renamed PluginRegistry to plugin::Registry. |
159 |
static bool register_builtin(plugin::Registry ®istry, |
1110.1.3
by Monty Taylor
Added ListenHandler as a member of PluginRegistry. |
160 |
plugin::Handle *, |
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
161 |
plugin::Handle **); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
162 |
static void unlock_variables(Session *session, struct system_variables *vars); |
163 |
static void cleanup_variables(Session *session, struct system_variables *vars); |
|
1
by brian
clean slate |
164 |
static void plugin_vars_free_values(sys_var *vars); |
165 |
static void plugin_opt_set_limits(struct my_option *options, |
|
166 |
const struct st_mysql_sys_var *opt); |
|
1110.1.5
by Monty Taylor
Renamed PluginRegistry to plugin::Registry. |
167 |
static void reap_plugins(plugin::Registry &plugins); |
1
by brian
clean slate |
168 |
|
169 |
||
170 |
/* declared in set_var.cc */
|
|
482
by Brian Aker
Remove uint. |
171 |
extern sys_var *intern_find_sys_var(const char *str, uint32_t length, bool no_error); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
172 |
extern bool throw_bounds_warning(Session *session, bool fixed, bool unsignd, |
1022.2.38
by Monty Taylor
Changed name to std::string. |
173 |
const std::string &name, int64_t val); |
174 |
||
175 |
static bool throw_bounds_warning(Session *session, bool fixed, bool unsignd, |
|
176 |
const char *name, int64_t val) |
|
177 |
{
|
|
178 |
const std::string name_str(name); |
|
179 |
return throw_bounds_warning(session, fixed, unsignd, name_str, val); |
|
180 |
}
|
|
1
by brian
clean slate |
181 |
|
182 |
/****************************************************************************
|
|
183 |
Value type thunks, allows the C world to play in the C++ world
|
|
184 |
****************************************************************************/
|
|
185 |
||
186 |
static int item_value_type(struct st_mysql_value *value) |
|
187 |
{
|
|
188 |
switch (((st_item_value_holder*)value)->item->result_type()) { |
|
189 |
case INT_RESULT: |
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
190 |
return DRIZZLE_VALUE_TYPE_INT; |
1
by brian
clean slate |
191 |
case REAL_RESULT: |
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
192 |
return DRIZZLE_VALUE_TYPE_REAL; |
1
by brian
clean slate |
193 |
default: |
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
194 |
return DRIZZLE_VALUE_TYPE_STRING; |
1
by brian
clean slate |
195 |
}
|
196 |
}
|
|
197 |
||
198 |
static const char *item_val_str(struct st_mysql_value *value, |
|
199 |
char *buffer, int *length) |
|
200 |
{
|
|
201 |
String str(buffer, *length, system_charset_info), *res; |
|
202 |
if (!(res= ((st_item_value_holder*)value)->item->val_str(&str))) |
|
203 |
return NULL; |
|
204 |
*length= res->length(); |
|
205 |
if (res->c_ptr_quick() == buffer) |
|
206 |
return buffer; |
|
207 |
||
208 |
/*
|
|
209 |
Lets be nice and create a temporary string since the
|
|
210 |
buffer was too small
|
|
211 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
212 |
return current_session->strmake(res->c_ptr_quick(), res->length()); |
1
by brian
clean slate |
213 |
}
|
214 |
||
215 |
||
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
216 |
static int item_val_int(struct st_mysql_value *value, int64_t *buf) |
1
by brian
clean slate |
217 |
{
|
218 |
Item *item= ((st_item_value_holder*)value)->item; |
|
219 |
*buf= item->val_int(); |
|
220 |
if (item->is_null()) |
|
221 |
return 1; |
|
222 |
return 0; |
|
223 |
}
|
|
224 |
||
225 |
||
226 |
static int item_val_real(struct st_mysql_value *value, double *buf) |
|
227 |
{
|
|
228 |
Item *item= ((st_item_value_holder*)value)->item; |
|
229 |
*buf= item->val_real(); |
|
230 |
if (item->is_null()) |
|
231 |
return 1; |
|
232 |
return 0; |
|
233 |
}
|
|
234 |
||
235 |
||
236 |
/****************************************************************************
|
|
237 |
Plugin support code
|
|
238 |
****************************************************************************/
|
|
239 |
||
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
240 |
static plugin::Library *plugin_dl_find(const LEX_STRING *dl) |
1
by brian
clean slate |
241 |
{
|
482
by Brian Aker
Remove uint. |
242 |
uint32_t i; |
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
243 |
plugin::Library *tmp; |
681
by Brian Aker
Style cleanup |
244 |
|
1
by brian
clean slate |
245 |
for (i= 0; i < plugin_dl_array.elements; i++) |
246 |
{
|
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
247 |
tmp= *dynamic_element(&plugin_dl_array, i, plugin::Library **); |
962.1.5
by Brian Aker
Remove ref_count from DLL plugin. |
248 |
if (! my_strnncoll(files_charset_info, |
481
by Brian Aker
Remove all of uchar. |
249 |
(const unsigned char *)dl->str, dl->length, |
250 |
(const unsigned char *)tmp->dl.str, tmp->dl.length)) |
|
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
251 |
return(tmp); |
1
by brian
clean slate |
252 |
}
|
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
253 |
return(0); |
1
by brian
clean slate |
254 |
}
|
255 |
||
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
256 |
static plugin::Library *plugin_dl_insert_or_reuse(plugin::Library *plugin_dl) |
1
by brian
clean slate |
257 |
{
|
482
by Brian Aker
Remove uint. |
258 |
uint32_t i; |
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
259 |
plugin::Library *tmp; |
681
by Brian Aker
Style cleanup |
260 |
|
1
by brian
clean slate |
261 |
for (i= 0; i < plugin_dl_array.elements; i++) |
262 |
{
|
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
263 |
tmp= *dynamic_element(&plugin_dl_array, i, plugin::Library **); |
1
by brian
clean slate |
264 |
{
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
265 |
memcpy(tmp, plugin_dl, sizeof(plugin::Library)); |
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
266 |
return(tmp); |
1
by brian
clean slate |
267 |
}
|
268 |
}
|
|
481
by Brian Aker
Remove all of uchar. |
269 |
if (insert_dynamic(&plugin_dl_array, (unsigned char*)&plugin_dl)) |
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
270 |
return(0); |
1
by brian
clean slate |
271 |
tmp= *dynamic_element(&plugin_dl_array, plugin_dl_array.elements - 1, |
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
272 |
plugin::Library **)= |
273 |
(plugin::Library *) memdup_root(&plugin_mem_root, |
|
274 |
(unsigned char*)plugin_dl, |
|
275 |
sizeof(plugin::Library)); |
|
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
276 |
return(tmp); |
1
by brian
clean slate |
277 |
}
|
278 |
||
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
279 |
static inline void free_plugin_mem(plugin::Library *p) |
1
by brian
clean slate |
280 |
{
|
281 |
if (p->handle) |
|
282 |
dlclose(p->handle); |
|
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
283 |
free(p->dl.str); |
1
by brian
clean slate |
284 |
}
|
285 |
||
286 |
||
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
287 |
static plugin::Library *plugin_dl_add(const LEX_STRING *dl, int report) |
1
by brian
clean slate |
288 |
{
|
534
by Monty Taylor
Removed stxnmov. Also deleted strstr which had already been removed. |
289 |
string dlpath; |
1054.2.11
by Monty Taylor
Removed copy_and_convert. |
290 |
uint32_t plugin_dir_len; |
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
291 |
plugin::Library *tmp, plugin_dl; |
1
by brian
clean slate |
292 |
void *sym; |
293 |
plugin_dir_len= strlen(opt_plugin_dir); |
|
534
by Monty Taylor
Removed stxnmov. Also deleted strstr which had already been removed. |
294 |
dlpath.reserve(FN_REFLEN); |
1
by brian
clean slate |
295 |
/*
|
296 |
Ensure that the dll doesn't have a path.
|
|
297 |
This is done to ensure that only approved libraries from the
|
|
298 |
plugin directory are used (to make this even remotely secure).
|
|
299 |
*/
|
|
266.1.26
by Monty Taylor
Removed my_strchr. |
300 |
if (strchr(dl->str, FN_LIBCHAR) || |
1
by brian
clean slate |
301 |
check_string_char_length((LEX_STRING *) dl, "", NAME_CHAR_LEN, |
302 |
system_charset_info, 1) || |
|
303 |
plugin_dir_len + dl->length + 1 >= FN_REFLEN) |
|
304 |
{
|
|
305 |
if (report & REPORT_TO_USER) |
|
306 |
my_error(ER_UDF_NO_PATHS, MYF(0)); |
|
307 |
if (report & REPORT_TO_LOG) |
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
308 |
errmsg_printf(ERRMSG_LVL_ERROR, "%s",ER(ER_UDF_NO_PATHS)); |
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
309 |
return(0); |
1
by brian
clean slate |
310 |
}
|
311 |
/* If this dll is already loaded just increase ref_count. */
|
|
312 |
if ((tmp= plugin_dl_find(dl))) |
|
313 |
{
|
|
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
314 |
return(tmp); |
1
by brian
clean slate |
315 |
}
|
212.6.1
by Mats Kindahl
Replacing all bzero() calls with memset() calls and removing the bzero.c file. |
316 |
memset(&plugin_dl, 0, sizeof(plugin_dl)); |
1
by brian
clean slate |
317 |
/* Compile dll path */
|
534
by Monty Taylor
Removed stxnmov. Also deleted strstr which had already been removed. |
318 |
dlpath.append(opt_plugin_dir); |
319 |
dlpath.append("/"); |
|
320 |
dlpath.append(dl->str); |
|
1
by brian
clean slate |
321 |
/* Open new dll handle */
|
534
by Monty Taylor
Removed stxnmov. Also deleted strstr which had already been removed. |
322 |
if (!(plugin_dl.handle= dlopen(dlpath.c_str(), RTLD_LAZY|RTLD_GLOBAL))) |
1
by brian
clean slate |
323 |
{
|
324 |
const char *errmsg=dlerror(); |
|
534
by Monty Taylor
Removed stxnmov. Also deleted strstr which had already been removed. |
325 |
uint32_t dlpathlen= dlpath.length(); |
326 |
if (!dlpath.compare(0, dlpathlen, errmsg)) |
|
1
by brian
clean slate |
327 |
{ // if errmsg starts from dlpath, trim this prefix. |
328 |
errmsg+=dlpathlen; |
|
329 |
if (*errmsg == ':') errmsg++; |
|
330 |
if (*errmsg == ' ') errmsg++; |
|
331 |
}
|
|
332 |
if (report & REPORT_TO_USER) |
|
534
by Monty Taylor
Removed stxnmov. Also deleted strstr which had already been removed. |
333 |
my_error(ER_CANT_OPEN_LIBRARY, MYF(0), dlpath.c_str(), errno, errmsg); |
1
by brian
clean slate |
334 |
if (report & REPORT_TO_LOG) |
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
335 |
errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_CANT_OPEN_LIBRARY), dlpath.c_str(), errno, errmsg); |
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
336 |
return(0); |
1
by brian
clean slate |
337 |
}
|
177.4.1
by mark
remove some useless version checking code from sql_plugin.cc |
338 |
|
1
by brian
clean slate |
339 |
/* Find plugin declarations */
|
340 |
if (!(sym= dlsym(plugin_dl.handle, plugin_declarations_sym))) |
|
341 |
{
|
|
342 |
free_plugin_mem(&plugin_dl); |
|
343 |
if (report & REPORT_TO_USER) |
|
344 |
my_error(ER_CANT_FIND_DL_ENTRY, MYF(0), plugin_declarations_sym); |
|
345 |
if (report & REPORT_TO_LOG) |
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
346 |
errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_CANT_FIND_DL_ENTRY), plugin_declarations_sym); |
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
347 |
return(0); |
1
by brian
clean slate |
348 |
}
|
349 |
||
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
350 |
plugin_dl.plugins= static_cast<plugin::Manifest *>(sym); |
1
by brian
clean slate |
351 |
|
352 |
/* Duplicate and convert dll name */
|
|
353 |
plugin_dl.dl.length= dl->length * files_charset_info->mbmaxlen + 1; |
|
1054.2.11
by Monty Taylor
Removed copy_and_convert. |
354 |
if (! (plugin_dl.dl.str= (char*) calloc(plugin_dl.dl.length, sizeof(char)))) |
1
by brian
clean slate |
355 |
{
|
356 |
free_plugin_mem(&plugin_dl); |
|
357 |
if (report & REPORT_TO_USER) |
|
358 |
my_error(ER_OUTOFMEMORY, MYF(0), plugin_dl.dl.length); |
|
359 |
if (report & REPORT_TO_LOG) |
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
360 |
errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_OUTOFMEMORY), plugin_dl.dl.length); |
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
361 |
return(0); |
1
by brian
clean slate |
362 |
}
|
1054.2.11
by Monty Taylor
Removed copy_and_convert. |
363 |
strcpy(plugin_dl.dl.str, dl->str); |
1
by brian
clean slate |
364 |
/* Add this dll to array */
|
365 |
if (! (tmp= plugin_dl_insert_or_reuse(&plugin_dl))) |
|
366 |
{
|
|
367 |
free_plugin_mem(&plugin_dl); |
|
368 |
if (report & REPORT_TO_USER) |
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
369 |
my_error(ER_OUTOFMEMORY, MYF(0), sizeof(plugin::Library)); |
1
by brian
clean slate |
370 |
if (report & REPORT_TO_LOG) |
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
371 |
errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_OUTOFMEMORY), |
372 |
sizeof(plugin::Library)); |
|
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
373 |
return(0); |
1
by brian
clean slate |
374 |
}
|
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
375 |
return(tmp); |
1
by brian
clean slate |
376 |
}
|
377 |
||
378 |
||
379 |
static void plugin_dl_del(const LEX_STRING *dl) |
|
380 |
{
|
|
482
by Brian Aker
Remove uint. |
381 |
uint32_t i; |
1
by brian
clean slate |
382 |
|
383 |
for (i= 0; i < plugin_dl_array.elements; i++) |
|
384 |
{
|
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
385 |
plugin::Library *tmp= *dynamic_element(&plugin_dl_array, i, |
386 |
plugin::Library **); |
|
962.1.5
by Brian Aker
Remove ref_count from DLL plugin. |
387 |
if (! my_strnncoll(files_charset_info, |
481
by Brian Aker
Remove all of uchar. |
388 |
(const unsigned char *)dl->str, dl->length, |
389 |
(const unsigned char *)tmp->dl.str, tmp->dl.length)) |
|
1
by brian
clean slate |
390 |
{
|
391 |
/* Do not remove this element, unless no other plugin uses this dll. */
|
|
392 |
{
|
|
393 |
free_plugin_mem(tmp); |
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
394 |
memset(tmp, 0, sizeof(plugin::Library)); |
1
by brian
clean slate |
395 |
}
|
396 |
break; |
|
397 |
}
|
|
398 |
}
|
|
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
399 |
return; |
1
by brian
clean slate |
400 |
}
|
401 |
||
402 |
||
403 |
||
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
404 |
static plugin::Handle *plugin_insert_or_reuse(plugin::Handle *plugin) |
1
by brian
clean slate |
405 |
{
|
481
by Brian Aker
Remove all of uchar. |
406 |
if (insert_dynamic(&plugin_array, (unsigned char*)&plugin)) |
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
407 |
return(0); |
1093.3.4
by Monty Taylor
Naming cleanups. |
408 |
plugin= *dynamic_element(&plugin_array, plugin_array.elements - 1, |
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
409 |
plugin::Handle **); |
1093.3.4
by Monty Taylor
Naming cleanups. |
410 |
return(plugin); |
1
by brian
clean slate |
411 |
}
|
412 |
||
413 |
||
414 |
/*
|
|
415 |
NOTE
|
|
416 |
Requires that a write-lock is held on LOCK_system_variables_hash
|
|
417 |
*/
|
|
1110.1.5
by Monty Taylor
Renamed PluginRegistry to plugin::Registry. |
418 |
static bool plugin_add(plugin::Registry ®istry, MEM_ROOT *tmp_root, |
1
by brian
clean slate |
419 |
const LEX_STRING *name, const LEX_STRING *dl, |
420 |
int *argc, char **argv, int report) |
|
421 |
{
|
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
422 |
plugin::Manifest *manifest; |
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
423 |
if (! initialized) |
424 |
return(0); |
|
425 |
||
971.1.54
by Monty Taylor
Trimmed out some plugin type stuff. |
426 |
if (registry.find(name)) |
1
by brian
clean slate |
427 |
{
|
428 |
if (report & REPORT_TO_USER) |
|
429 |
my_error(ER_UDF_EXISTS, MYF(0), name->str); |
|
430 |
if (report & REPORT_TO_LOG) |
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
431 |
errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_UDF_EXISTS), name->str); |
163
by Brian Aker
Merge Monty's code. |
432 |
return(true); |
1
by brian
clean slate |
433 |
}
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
434 |
plugin::Library *library= plugin_dl_add(dl, report); |
1093.3.4
by Monty Taylor
Naming cleanups. |
435 |
if (library == NULL) |
436 |
return true; |
|
437 |
||
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
438 |
plugin::Handle *tmp= NULL; |
1
by brian
clean slate |
439 |
/* Find plugin by name */
|
1093.3.4
by Monty Taylor
Naming cleanups. |
440 |
for (manifest= library->plugins; manifest->name; manifest++) |
1
by brian
clean slate |
441 |
{
|
971.1.55
by Monty Taylor
Removed now meaningless plugin_type. |
442 |
if (! my_strnncoll(system_charset_info, |
481
by Brian Aker
Remove all of uchar. |
443 |
(const unsigned char *)name->str, name->length, |
1093.3.4
by Monty Taylor
Naming cleanups. |
444 |
(const unsigned char *)manifest->name, |
445 |
strlen(manifest->name))) |
|
1
by brian
clean slate |
446 |
{
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
447 |
tmp= new (std::nothrow) plugin::Handle(manifest, library); |
1093.3.4
by Monty Taylor
Naming cleanups. |
448 |
if (tmp == NULL) |
449 |
return true; |
|
177.4.1
by mark
remove some useless version checking code from sql_plugin.cc |
450 |
|
1093.3.4
by Monty Taylor
Naming cleanups. |
451 |
if (!test_plugin_options(tmp_root, tmp, argc, argv)) |
1
by brian
clean slate |
452 |
{
|
1093.3.4
by Monty Taylor
Naming cleanups. |
453 |
if ((tmp= plugin_insert_or_reuse(tmp))) |
1
by brian
clean slate |
454 |
{
|
1093.3.4
by Monty Taylor
Naming cleanups. |
455 |
registry.add(tmp); |
456 |
init_alloc_root(&tmp->mem_root, 4096, 4096); |
|
873.2.21
by Monty Taylor
Removed the HASH for plugin_hash. |
457 |
return(false); |
1
by brian
clean slate |
458 |
}
|
1093.3.4
by Monty Taylor
Naming cleanups. |
459 |
mysql_del_sys_var_chain(tmp->system_vars); |
1
by brian
clean slate |
460 |
goto err; |
461 |
}
|
|
462 |
/* plugin was disabled */
|
|
463 |
plugin_dl_del(dl); |
|
163
by Brian Aker
Merge Monty's code. |
464 |
return(false); |
1
by brian
clean slate |
465 |
}
|
466 |
}
|
|
467 |
if (report & REPORT_TO_USER) |
|
468 |
my_error(ER_CANT_FIND_DL_ENTRY, MYF(0), name->str); |
|
469 |
if (report & REPORT_TO_LOG) |
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
470 |
errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_CANT_FIND_DL_ENTRY), name->str); |
1
by brian
clean slate |
471 |
err: |
472 |
plugin_dl_del(dl); |
|
163
by Brian Aker
Merge Monty's code. |
473 |
return(true); |
1
by brian
clean slate |
474 |
}
|
475 |
||
476 |
||
1110.1.5
by Monty Taylor
Renamed PluginRegistry to plugin::Registry. |
477 |
static void plugin_del(plugin::Registry ®istry, plugin::Handle *plugin) |
1
by brian
clean slate |
478 |
{
|
965.1.1
by Brian Aker
Refactor plugin loading to remove mask (one step closer to getting rid of |
479 |
if (plugin->isInited) |
480 |
{
|
|
1093.3.4
by Monty Taylor
Naming cleanups. |
481 |
if (plugin->getManifest().status_vars) |
965.1.1
by Brian Aker
Refactor plugin loading to remove mask (one step closer to getting rid of |
482 |
{
|
1093.3.4
by Monty Taylor
Naming cleanups. |
483 |
remove_status_vars(plugin->getManifest().status_vars); |
965.1.1
by Brian Aker
Refactor plugin loading to remove mask (one step closer to getting rid of |
484 |
}
|
485 |
||
1093.3.4
by Monty Taylor
Naming cleanups. |
486 |
if (plugin->getManifest().deinit) |
487 |
plugin->getManifest().deinit(registry); |
|
965.1.1
by Brian Aker
Refactor plugin loading to remove mask (one step closer to getting rid of |
488 |
}
|
489 |
||
1
by brian
clean slate |
490 |
/* Free allocated strings before deleting the plugin. */
|
491 |
plugin_vars_free_values(plugin->system_vars); |
|
492 |
if (plugin->plugin_dl) |
|
493 |
plugin_dl_del(&plugin->plugin_dl->dl); |
|
965.1.1
by Brian Aker
Refactor plugin loading to remove mask (one step closer to getting rid of |
494 |
plugin->isInited= false; |
658
by Brian Aker
Part removal of my_pthread.h |
495 |
pthread_rwlock_wrlock(&LOCK_system_variables_hash); |
1
by brian
clean slate |
496 |
mysql_del_sys_var_chain(plugin->system_vars); |
658
by Brian Aker
Part removal of my_pthread.h |
497 |
pthread_rwlock_unlock(&LOCK_system_variables_hash); |
1093.3.4
by Monty Taylor
Naming cleanups. |
498 |
delete plugin; |
1
by brian
clean slate |
499 |
}
|
500 |
||
1110.1.5
by Monty Taylor
Renamed PluginRegistry to plugin::Registry. |
501 |
static void reap_plugins(plugin::Registry &plugins) |
1
by brian
clean slate |
502 |
{
|
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
503 |
size_t count; |
504 |
uint32_t idx; |
|
1119.1.2
by Monty Taylor
Fixed style issues. /me smacks /me. |
505 |
plugin::Handle *plugin; |
660.1.6
by Eric Herman
trailing whitespace fixup |
506 |
|
1
by brian
clean slate |
507 |
count= plugin_array.elements; |
508 |
||
509 |
for (idx= 0; idx < count; idx++) |
|
510 |
{
|
|
1119.1.2
by Monty Taylor
Fixed style issues. /me smacks /me. |
511 |
plugin= *dynamic_element(&plugin_array, idx, plugin::Handle **); |
1110.1.3
by Monty Taylor
Added ListenHandler as a member of PluginRegistry. |
512 |
plugin_del(plugins, plugin); |
688
by Brian Aker
Second pass through memory allocation issues (this solves the ones around |
513 |
}
|
1101.1.27
by Monty Taylor
Fixed the plugin string valgrind leak. |
514 |
drizzle_del_plugin_sysvar(); |
1
by brian
clean slate |
515 |
}
|
516 |
||
1119.1.1
by Monty Taylor
--help doesn't need --datadir to work. |
517 |
|
1119.1.2
by Monty Taylor
Fixed style issues. /me smacks /me. |
518 |
static void plugin_initialize_vars(plugin::Handle *plugin) |
1
by brian
clean slate |
519 |
{
|
1093.3.4
by Monty Taylor
Naming cleanups. |
520 |
if (plugin->getManifest().status_vars) |
1
by brian
clean slate |
521 |
{
|
1093.3.4
by Monty Taylor
Naming cleanups. |
522 |
add_status_vars(plugin->getManifest().status_vars); // add_status_vars makes a copy |
1
by brian
clean slate |
523 |
}
|
524 |
||
525 |
/*
|
|
526 |
set the plugin attribute of plugin's sys vars so they are pointing
|
|
527 |
to the active plugin
|
|
528 |
*/
|
|
529 |
if (plugin->system_vars) |
|
530 |
{
|
|
531 |
sys_var_pluginvar *var= plugin->system_vars->cast_pluginvar(); |
|
532 |
for (;;) |
|
533 |
{
|
|
534 |
var->plugin= plugin; |
|
1055.2.20
by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters. |
535 |
if (! var->getNext()) |
1
by brian
clean slate |
536 |
break; |
1055.2.20
by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters. |
537 |
var= var->getNext()->cast_pluginvar(); |
1
by brian
clean slate |
538 |
}
|
539 |
}
|
|
1119.1.1
by Monty Taylor
--help doesn't need --datadir to work. |
540 |
}
|
541 |
||
542 |
||
543 |
static bool plugin_initialize(plugin::Registry ®istry, |
|
1119.1.2
by Monty Taylor
Fixed style issues. /me smacks /me. |
544 |
plugin::Handle *plugin) |
1119.1.1
by Monty Taylor
--help doesn't need --datadir to work. |
545 |
{
|
546 |
assert(plugin->isInited == false); |
|
547 |
||
548 |
if (plugin->getManifest().init) |
|
549 |
{
|
|
550 |
if (plugin->getManifest().init(registry)) |
|
551 |
{
|
|
552 |
errmsg_printf(ERRMSG_LVL_ERROR, |
|
553 |
_("Plugin '%s' init function returned error.\n"), |
|
554 |
plugin->getName().c_str()); |
|
555 |
return true; |
|
556 |
}
|
|
557 |
}
|
|
558 |
plugin->isInited= true; |
|
559 |
||
1
by brian
clean slate |
560 |
|
965.1.1
by Brian Aker
Refactor plugin loading to remove mask (one step closer to getting rid of |
561 |
return false; |
1
by brian
clean slate |
562 |
}
|
563 |
||
564 |
||
481
by Brian Aker
Remove all of uchar. |
565 |
extern "C" unsigned char *get_bookmark_hash_key(const unsigned char *, size_t *, bool); |
566 |
||
567 |
||
654
by Brian Aker
Remove unused (yet more) |
568 |
unsigned char *get_bookmark_hash_key(const unsigned char *buff, size_t *length, bool) |
1
by brian
clean slate |
569 |
{
|
570 |
struct st_bookmark *var= (st_bookmark *)buff; |
|
571 |
*length= var->name_len + 1; |
|
481
by Brian Aker
Remove all of uchar. |
572 |
return (unsigned char*) var->key; |
1
by brian
clean slate |
573 |
}
|
574 |
||
575 |
||
576 |
/*
|
|
577 |
The logic is that we first load and initialize all compiled in plugins.
|
|
578 |
From there we load up the dynamic types (assuming we have not been told to
|
|
579 |
skip this part).
|
|
580 |
||
581 |
Finally we initialize everything, aka the dynamic that have yet to initialize.
|
|
582 |
*/
|
|
1110.1.5
by Monty Taylor
Renamed PluginRegistry to plugin::Registry. |
583 |
int plugin_init(plugin::Registry ®istry, int *argc, char **argv, int flags) |
1
by brian
clean slate |
584 |
{
|
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
585 |
uint32_t idx; |
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
586 |
plugin::Manifest **builtins; |
587 |
plugin::Manifest *manifest; |
|
588 |
plugin::Handle *handle; |
|
1
by brian
clean slate |
589 |
MEM_ROOT tmp_root; |
590 |
||
591 |
if (initialized) |
|
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
592 |
return(0); |
1
by brian
clean slate |
593 |
|
594 |
init_alloc_root(&plugin_mem_root, 4096, 4096); |
|
595 |
init_alloc_root(&tmp_root, 4096, 4096); |
|
596 |
||
597 |
if (hash_init(&bookmark_hash, &my_charset_bin, 16, 0, 0, |
|
598 |
get_bookmark_hash_key, NULL, HASH_UNIQUE)) |
|
599 |
goto err; |
|
600 |
||
601 |
||
602 |
if (my_init_dynamic_array(&plugin_dl_array, |
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
603 |
sizeof(plugin::Library *),16,16) || |
1
by brian
clean slate |
604 |
my_init_dynamic_array(&plugin_array, |
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
605 |
sizeof(plugin::Handle *),16,16)) |
1
by brian
clean slate |
606 |
goto err; |
607 |
||
608 |
initialized= 1; |
|
609 |
||
610 |
/*
|
|
611 |
First we register builtin plugins
|
|
612 |
*/
|
|
992.1.39
by Monty Taylor
Removed the m4-based plugin system. |
613 |
for (builtins= drizzled_builtins; *builtins; builtins++) |
1
by brian
clean slate |
614 |
{
|
1093.3.4
by Monty Taylor
Naming cleanups. |
615 |
for (manifest= *builtins; manifest->name; manifest++) |
1
by brian
clean slate |
616 |
{
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
617 |
handle= new (std::nothrow) plugin::Handle(manifest); |
1093.3.4
by Monty Taylor
Naming cleanups. |
618 |
if (handle == NULL) |
619 |
return true; |
|
1
by brian
clean slate |
620 |
|
621 |
free_root(&tmp_root, MYF(MY_MARK_BLOCKS_FREE)); |
|
1093.3.4
by Monty Taylor
Naming cleanups. |
622 |
if (test_plugin_options(&tmp_root, handle, argc, argv)) |
1
by brian
clean slate |
623 |
continue; |
624 |
||
1110.1.3
by Monty Taylor
Added ListenHandler as a member of PluginRegistry. |
625 |
if (register_builtin(registry, handle, &handle)) |
1
by brian
clean slate |
626 |
goto err_unlock; |
627 |
||
1119.1.1
by Monty Taylor
--help doesn't need --datadir to work. |
628 |
plugin_initialize_vars(handle); |
1
by brian
clean slate |
629 |
|
1119.1.2
by Monty Taylor
Fixed style issues. /me smacks /me. |
630 |
if (! (flags & PLUGIN_INIT_SKIP_INITIALIZATION)) |
1119.1.1
by Monty Taylor
--help doesn't need --datadir to work. |
631 |
{
|
632 |
if (plugin_initialize(registry, handle)) |
|
633 |
goto err_unlock; |
|
634 |
}
|
|
1
by brian
clean slate |
635 |
}
|
636 |
}
|
|
637 |
||
638 |
||
639 |
/* Register all dynamic plugins */
|
|
1119.1.2
by Monty Taylor
Fixed style issues. /me smacks /me. |
640 |
if (! (flags & PLUGIN_INIT_SKIP_DYNAMIC_LOADING)) |
1
by brian
clean slate |
641 |
{
|
642 |
if (opt_plugin_load) |
|
1110.1.3
by Monty Taylor
Added ListenHandler as a member of PluginRegistry. |
643 |
plugin_load_list(registry, &tmp_root, argc, argv, opt_plugin_load); |
1
by brian
clean slate |
644 |
}
|
645 |
||
646 |
if (flags & PLUGIN_INIT_SKIP_INITIALIZATION) |
|
647 |
goto end; |
|
648 |
||
649 |
/*
|
|
650 |
Now we initialize all remaining plugins
|
|
651 |
*/
|
|
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
652 |
for (idx= 0; idx < plugin_array.elements; idx++) |
1
by brian
clean slate |
653 |
{
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
654 |
handle= *dynamic_element(&plugin_array, idx, plugin::Handle **); |
1093.3.4
by Monty Taylor
Naming cleanups. |
655 |
if (handle->isInited == false) |
1
by brian
clean slate |
656 |
{
|
1119.1.1
by Monty Taylor
--help doesn't need --datadir to work. |
657 |
plugin_initialize_vars(handle); |
658 |
||
1110.1.3
by Monty Taylor
Added ListenHandler as a member of PluginRegistry. |
659 |
if (plugin_initialize(registry, handle)) |
660 |
plugin_del(registry, handle); |
|
1
by brian
clean slate |
661 |
}
|
662 |
}
|
|
663 |
||
664 |
||
665 |
end: |
|
666 |
free_root(&tmp_root, MYF(0)); |
|
667 |
||
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
668 |
return(0); |
1
by brian
clean slate |
669 |
|
670 |
err_unlock: |
|
671 |
err: |
|
672 |
free_root(&tmp_root, MYF(0)); |
|
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
673 |
return(1); |
1
by brian
clean slate |
674 |
}
|
675 |
||
676 |
||
1110.1.5
by Monty Taylor
Renamed PluginRegistry to plugin::Registry. |
677 |
static bool register_builtin(plugin::Registry ®istry, |
1110.1.3
by Monty Taylor
Added ListenHandler as a member of PluginRegistry. |
678 |
plugin::Handle *tmp, |
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
679 |
plugin::Handle **ptr) |
1
by brian
clean slate |
680 |
{
|
681 |
||
965.1.1
by Brian Aker
Refactor plugin loading to remove mask (one step closer to getting rid of |
682 |
tmp->isInited= false; |
1
by brian
clean slate |
683 |
tmp->plugin_dl= 0; |
684 |
||
481
by Brian Aker
Remove all of uchar. |
685 |
if (insert_dynamic(&plugin_array, (unsigned char*)&tmp)) |
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
686 |
return(1); |
1
by brian
clean slate |
687 |
|
688 |
*ptr= *dynamic_element(&plugin_array, plugin_array.elements - 1, |
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
689 |
plugin::Handle **); |
1
by brian
clean slate |
690 |
|
971.1.54
by Monty Taylor
Trimmed out some plugin type stuff. |
691 |
registry.add(*ptr); |
1
by brian
clean slate |
692 |
|
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
693 |
return(0); |
1
by brian
clean slate |
694 |
}
|
695 |
||
696 |
||
697 |
/*
|
|
698 |
called only by plugin_init()
|
|
699 |
*/
|
|
1110.1.5
by Monty Taylor
Renamed PluginRegistry to plugin::Registry. |
700 |
static bool plugin_load_list(plugin::Registry &plugins, |
1110.1.3
by Monty Taylor
Added ListenHandler as a member of PluginRegistry. |
701 |
MEM_ROOT *tmp_root, int *argc, char **argv, |
1
by brian
clean slate |
702 |
const char *list) |
703 |
{
|
|
704 |
char buffer[FN_REFLEN]; |
|
705 |
LEX_STRING name= {buffer, 0}, dl= {NULL, 0}, *str= &name; |
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
706 |
plugin::Library *plugin_dl; |
707 |
plugin::Manifest *plugin; |
|
1
by brian
clean slate |
708 |
char *p= buffer; |
709 |
while (list) |
|
710 |
{
|
|
711 |
if (p == buffer + sizeof(buffer) - 1) |
|
712 |
{
|
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
713 |
errmsg_printf(ERRMSG_LVL_ERROR, _("plugin-load parameter too long")); |
163
by Brian Aker
Merge Monty's code. |
714 |
return(true); |
1
by brian
clean slate |
715 |
}
|
716 |
||
717 |
switch ((*(p++)= *(list++))) { |
|
718 |
case '\0': |
|
719 |
list= NULL; /* terminate the loop */ |
|
720 |
/* fall through */
|
|
721 |
case ':': /* can't use this as delimiter as it may be drive letter */ |
|
722 |
case ';': |
|
723 |
str->str[str->length]= '\0'; |
|
724 |
if (str == &name) // load all plugins in named module |
|
725 |
{
|
|
726 |
if (!name.length) |
|
727 |
{
|
|
728 |
p--; /* reset pointer */ |
|
729 |
continue; |
|
730 |
}
|
|
731 |
||
732 |
dl= name; |
|
733 |
if ((plugin_dl= plugin_dl_add(&dl, REPORT_TO_LOG))) |
|
734 |
{
|
|
177.4.3
by mark
ripped out more plugin ABI and API version checking, and plugin versions are now strings |
735 |
for (plugin= plugin_dl->plugins; plugin->name; plugin++) |
1
by brian
clean slate |
736 |
{
|
737 |
name.str= (char *) plugin->name; |
|
738 |
name.length= strlen(name.str); |
|
739 |
||
740 |
free_root(tmp_root, MYF(MY_MARK_BLOCKS_FREE)); |
|
1110.1.3
by Monty Taylor
Added ListenHandler as a member of PluginRegistry. |
741 |
if (plugin_add(plugins, tmp_root, &name, &dl, |
742 |
argc, argv, REPORT_TO_LOG)) |
|
1
by brian
clean slate |
743 |
goto error; |
744 |
}
|
|
745 |
plugin_dl_del(&dl); // reduce ref count |
|
746 |
}
|
|
747 |
}
|
|
748 |
else
|
|
749 |
{
|
|
750 |
free_root(tmp_root, MYF(MY_MARK_BLOCKS_FREE)); |
|
1110.1.3
by Monty Taylor
Added ListenHandler as a member of PluginRegistry. |
751 |
if (plugin_add(plugins, tmp_root, &name, &dl, |
752 |
argc, argv, REPORT_TO_LOG)) |
|
1
by brian
clean slate |
753 |
goto error; |
754 |
}
|
|
755 |
name.length= dl.length= 0; |
|
756 |
dl.str= NULL; name.str= p= buffer; |
|
757 |
str= &name; |
|
758 |
continue; |
|
759 |
case '=': |
|
760 |
case '#': |
|
761 |
if (str == &name) |
|
762 |
{
|
|
763 |
name.str[name.length]= '\0'; |
|
764 |
str= &dl; |
|
765 |
str->str= p; |
|
766 |
continue; |
|
767 |
}
|
|
768 |
default: |
|
769 |
str->length++; |
|
770 |
continue; |
|
771 |
}
|
|
772 |
}
|
|
163
by Brian Aker
Merge Monty's code. |
773 |
return(false); |
1
by brian
clean slate |
774 |
error: |
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
775 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Couldn't load plugin named '%s' with soname '%s'."), |
1
by brian
clean slate |
776 |
name.str, dl.str); |
163
by Brian Aker
Merge Monty's code. |
777 |
return(true); |
1
by brian
clean slate |
778 |
}
|
779 |
||
780 |
||
1110.1.5
by Monty Taylor
Renamed PluginRegistry to plugin::Registry. |
781 |
void plugin_shutdown(plugin::Registry ®istry) |
1
by brian
clean slate |
782 |
{
|
962.1.6
by Brian Aker
Cut down on shutdown loop of plugins (cutting stuff out in order to simplify |
783 |
uint32_t idx; |
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
784 |
size_t count= plugin_array.elements; |
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
785 |
vector<plugin::Handle *> plugins; |
786 |
vector<plugin::Library *> dl; |
|
1
by brian
clean slate |
787 |
|
788 |
if (initialized) |
|
789 |
{
|
|
790 |
reap_needed= true; |
|
791 |
||
1110.1.3
by Monty Taylor
Added ListenHandler as a member of PluginRegistry. |
792 |
reap_plugins(registry); |
962.1.6
by Brian Aker
Cut down on shutdown loop of plugins (cutting stuff out in order to simplify |
793 |
unlock_variables(NULL, &global_system_variables); |
794 |
unlock_variables(NULL, &max_system_variables); |
|
1
by brian
clean slate |
795 |
|
796 |
cleanup_variables(NULL, &global_system_variables); |
|
797 |
cleanup_variables(NULL, &max_system_variables); |
|
798 |
||
799 |
initialized= 0; |
|
800 |
}
|
|
801 |
||
802 |
/* Dispose of the memory */
|
|
803 |
||
804 |
delete_dynamic(&plugin_array); |
|
805 |
||
806 |
count= plugin_dl_array.elements; |
|
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
807 |
dl.reserve(count); |
808 |
for (idx= 0; idx < count; idx++) |
|
809 |
dl.push_back(*dynamic_element(&plugin_dl_array, idx, |
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
810 |
plugin::Library **)); |
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
811 |
for (idx= 0; idx < count; idx++) |
812 |
free_plugin_mem(dl[idx]); |
|
1
by brian
clean slate |
813 |
delete_dynamic(&plugin_dl_array); |
814 |
||
815 |
hash_free(&bookmark_hash); |
|
816 |
free_root(&plugin_mem_root, MYF(0)); |
|
817 |
||
818 |
global_variables_dynamic_size= 0; |
|
819 |
}
|
|
820 |
||
821 |
/****************************************************************************
|
|
822 |
Internal type declarations for variables support
|
|
823 |
****************************************************************************/
|
|
824 |
||
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
825 |
#undef DRIZZLE_SYSVAR_NAME
|
826 |
#define DRIZZLE_SYSVAR_NAME(name) name
|
|
1
by brian
clean slate |
827 |
#define PLUGIN_VAR_TYPEMASK 0x007f
|
828 |
||
829 |
#define EXTRA_OPTIONS 3 /* options for: 'foo', 'plugin-foo' and NULL */ |
|
830 |
||
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
831 |
typedef DECLARE_DRIZZLE_SYSVAR_BASIC(sysvar_bool_t, bool); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
832 |
typedef DECLARE_DRIZZLE_SessionVAR_BASIC(sessionvar_bool_t, bool); |
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
833 |
typedef DECLARE_DRIZZLE_SYSVAR_BASIC(sysvar_str_t, char *); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
834 |
typedef DECLARE_DRIZZLE_SessionVAR_BASIC(sessionvar_str_t, char *); |
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
835 |
|
836 |
typedef DECLARE_DRIZZLE_SYSVAR_TYPELIB(sysvar_enum_t, unsigned long); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
837 |
typedef DECLARE_DRIZZLE_SessionVAR_TYPELIB(sessionvar_enum_t, unsigned long); |
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
838 |
typedef DECLARE_DRIZZLE_SYSVAR_TYPELIB(sysvar_set_t, uint64_t); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
839 |
typedef DECLARE_DRIZZLE_SessionVAR_TYPELIB(sessionvar_set_t, uint64_t); |
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
840 |
|
841 |
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_int_t, int); |
|
842 |
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_long_t, long); |
|
843 |
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_int64_t_t, int64_t); |
|
844 |
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_uint_t, uint); |
|
845 |
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_ulong_t, ulong); |
|
846 |
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_uint64_t_t, uint64_t); |
|
847 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
848 |
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_int_t, int); |
849 |
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_long_t, long); |
|
850 |
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_int64_t_t, int64_t); |
|
851 |
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_uint_t, uint); |
|
852 |
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_ulong_t, ulong); |
|
853 |
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_uint64_t_t, uint64_t); |
|
1
by brian
clean slate |
854 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
855 |
typedef bool *(*mysql_sys_var_ptr_p)(Session* a_session, int offset); |
1
by brian
clean slate |
856 |
|
857 |
||
858 |
/****************************************************************************
|
|
859 |
default variable data check and update functions
|
|
860 |
****************************************************************************/
|
|
861 |
||
654
by Brian Aker
Remove unused (yet more) |
862 |
static int check_func_bool(Session *, struct st_mysql_sys_var *var, |
1
by brian
clean slate |
863 |
void *save, st_mysql_value *value) |
864 |
{
|
|
865 |
char buff[STRING_BUFFER_USUAL_SIZE]; |
|
866 |
const char *strvalue= "NULL", *str; |
|
867 |
int result, length; |
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
868 |
int64_t tmp; |
1
by brian
clean slate |
869 |
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
870 |
if (value->value_type(value) == DRIZZLE_VALUE_TYPE_STRING) |
1
by brian
clean slate |
871 |
{
|
872 |
length= sizeof(buff); |
|
873 |
if (!(str= value->val_str(value, buff, &length)) || |
|
874 |
(result= find_type(&bool_typelib, str, length, 1)-1) < 0) |
|
875 |
{
|
|
876 |
if (str) |
|
877 |
strvalue= str; |
|
878 |
goto err; |
|
879 |
}
|
|
880 |
}
|
|
881 |
else
|
|
882 |
{
|
|
883 |
if (value->val_int(value, &tmp) < 0) |
|
884 |
goto err; |
|
885 |
if (tmp > 1) |
|
886 |
{
|
|
887 |
llstr(tmp, buff); |
|
888 |
strvalue= buff; |
|
889 |
goto err; |
|
890 |
}
|
|
891 |
result= (int) tmp; |
|
892 |
}
|
|
893 |
*(int*)save= -result; |
|
894 |
return 0; |
|
895 |
err: |
|
896 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->name, strvalue); |
|
897 |
return 1; |
|
898 |
}
|
|
899 |
||
900 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
901 |
static int check_func_int(Session *session, struct st_mysql_sys_var *var, |
1
by brian
clean slate |
902 |
void *save, st_mysql_value *value) |
903 |
{
|
|
143
by Brian Aker
Bool cleanup. |
904 |
bool fixed; |
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
905 |
int64_t tmp; |
1
by brian
clean slate |
906 |
struct my_option options; |
907 |
value->val_int(value, &tmp); |
|
908 |
plugin_opt_set_limits(&options, var); |
|
909 |
||
910 |
if (var->flags & PLUGIN_VAR_UNSIGNED) |
|
895
by Brian Aker
Completion (?) of uint conversion. |
911 |
*(uint32_t *)save= (uint32_t) getopt_ull_limit_value((uint64_t) tmp, &options, |
1
by brian
clean slate |
912 |
&fixed); |
913 |
else
|
|
914 |
*(int *)save= (int) getopt_ll_limit_value(tmp, &options, &fixed); |
|
915 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
916 |
return throw_bounds_warning(session, fixed, var->flags & PLUGIN_VAR_UNSIGNED, |
152
by Brian Aker
longlong replacement |
917 |
var->name, (int64_t) tmp); |
1
by brian
clean slate |
918 |
}
|
919 |
||
920 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
921 |
static int check_func_long(Session *session, struct st_mysql_sys_var *var, |
1
by brian
clean slate |
922 |
void *save, st_mysql_value *value) |
923 |
{
|
|
143
by Brian Aker
Bool cleanup. |
924 |
bool fixed; |
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
925 |
int64_t tmp; |
1
by brian
clean slate |
926 |
struct my_option options; |
927 |
value->val_int(value, &tmp); |
|
928 |
plugin_opt_set_limits(&options, var); |
|
929 |
||
930 |
if (var->flags & PLUGIN_VAR_UNSIGNED) |
|
151
by Brian Aker
Ulonglong to uint64_t |
931 |
*(ulong *)save= (ulong) getopt_ull_limit_value((uint64_t) tmp, &options, |
1
by brian
clean slate |
932 |
&fixed); |
933 |
else
|
|
934 |
*(long *)save= (long) getopt_ll_limit_value(tmp, &options, &fixed); |
|
935 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
936 |
return throw_bounds_warning(session, fixed, var->flags & PLUGIN_VAR_UNSIGNED, |
152
by Brian Aker
longlong replacement |
937 |
var->name, (int64_t) tmp); |
1
by brian
clean slate |
938 |
}
|
939 |
||
940 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
941 |
static int check_func_int64_t(Session *session, struct st_mysql_sys_var *var, |
1
by brian
clean slate |
942 |
void *save, st_mysql_value *value) |
943 |
{
|
|
143
by Brian Aker
Bool cleanup. |
944 |
bool fixed; |
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
945 |
int64_t tmp; |
1
by brian
clean slate |
946 |
struct my_option options; |
947 |
value->val_int(value, &tmp); |
|
948 |
plugin_opt_set_limits(&options, var); |
|
949 |
||
950 |
if (var->flags & PLUGIN_VAR_UNSIGNED) |
|
151
by Brian Aker
Ulonglong to uint64_t |
951 |
*(uint64_t *)save= getopt_ull_limit_value((uint64_t) tmp, &options, |
1
by brian
clean slate |
952 |
&fixed); |
953 |
else
|
|
152
by Brian Aker
longlong replacement |
954 |
*(int64_t *)save= getopt_ll_limit_value(tmp, &options, &fixed); |
1
by brian
clean slate |
955 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
956 |
return throw_bounds_warning(session, fixed, var->flags & PLUGIN_VAR_UNSIGNED, |
152
by Brian Aker
longlong replacement |
957 |
var->name, (int64_t) tmp); |
1
by brian
clean slate |
958 |
}
|
959 |
||
654
by Brian Aker
Remove unused (yet more) |
960 |
static int check_func_str(Session *session, struct st_mysql_sys_var *, |
1
by brian
clean slate |
961 |
void *save, st_mysql_value *value) |
962 |
{
|
|
963 |
char buff[STRING_BUFFER_USUAL_SIZE]; |
|
964 |
const char *str; |
|
965 |
int length; |
|
966 |
||
967 |
length= sizeof(buff); |
|
968 |
if ((str= value->val_str(value, buff, &length))) |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
969 |
str= session->strmake(str, length); |
1
by brian
clean slate |
970 |
*(const char**)save= str; |
971 |
return 0; |
|
972 |
}
|
|
973 |
||
974 |
||
654
by Brian Aker
Remove unused (yet more) |
975 |
static int check_func_enum(Session *, struct st_mysql_sys_var *var, |
1
by brian
clean slate |
976 |
void *save, st_mysql_value *value) |
977 |
{
|
|
978 |
char buff[STRING_BUFFER_USUAL_SIZE]; |
|
979 |
const char *strvalue= "NULL", *str; |
|
980 |
TYPELIB *typelib; |
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
981 |
int64_t tmp; |
1
by brian
clean slate |
982 |
long result; |
983 |
int length; |
|
984 |
||
520.1.21
by Brian Aker
THD -> Session rename |
985 |
if (var->flags & PLUGIN_VAR_SessionLOCAL) |
520.1.22
by Brian Aker
Second pass of thd cleanup |
986 |
typelib= ((sessionvar_enum_t*) var)->typelib; |
1
by brian
clean slate |
987 |
else
|
988 |
typelib= ((sysvar_enum_t*) var)->typelib; |
|
989 |
||
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
990 |
if (value->value_type(value) == DRIZZLE_VALUE_TYPE_STRING) |
1
by brian
clean slate |
991 |
{
|
992 |
length= sizeof(buff); |
|
993 |
if (!(str= value->val_str(value, buff, &length))) |
|
994 |
goto err; |
|
995 |
if ((result= (long)find_type(typelib, str, length, 1)-1) < 0) |
|
996 |
{
|
|
997 |
strvalue= str; |
|
998 |
goto err; |
|
999 |
}
|
|
1000 |
}
|
|
1001 |
else
|
|
1002 |
{
|
|
1003 |
if (value->val_int(value, &tmp)) |
|
1004 |
goto err; |
|
1005 |
if (tmp >= typelib->count) |
|
1006 |
{
|
|
1007 |
llstr(tmp, buff); |
|
1008 |
strvalue= buff; |
|
1009 |
goto err; |
|
1010 |
}
|
|
1011 |
result= (long) tmp; |
|
1012 |
}
|
|
1013 |
*(long*)save= result; |
|
1014 |
return 0; |
|
1015 |
err: |
|
1016 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->name, strvalue); |
|
1017 |
return 1; |
|
1018 |
}
|
|
1019 |
||
1020 |
||
654
by Brian Aker
Remove unused (yet more) |
1021 |
static int check_func_set(Session *, struct st_mysql_sys_var *var, |
1
by brian
clean slate |
1022 |
void *save, st_mysql_value *value) |
1023 |
{
|
|
1024 |
char buff[STRING_BUFFER_USUAL_SIZE], *error= 0; |
|
1025 |
const char *strvalue= "NULL", *str; |
|
1026 |
TYPELIB *typelib; |
|
151
by Brian Aker
Ulonglong to uint64_t |
1027 |
uint64_t result; |
482
by Brian Aker
Remove uint. |
1028 |
uint32_t error_len; |
1
by brian
clean slate |
1029 |
bool not_used; |
1030 |
int length; |
|
1031 |
||
520.1.21
by Brian Aker
THD -> Session rename |
1032 |
if (var->flags & PLUGIN_VAR_SessionLOCAL) |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1033 |
typelib= ((sessionvar_set_t*) var)->typelib; |
1
by brian
clean slate |
1034 |
else
|
1035 |
typelib= ((sysvar_set_t*)var)->typelib; |
|
1036 |
||
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
1037 |
if (value->value_type(value) == DRIZZLE_VALUE_TYPE_STRING) |
1
by brian
clean slate |
1038 |
{
|
1039 |
length= sizeof(buff); |
|
1040 |
if (!(str= value->val_str(value, buff, &length))) |
|
1041 |
goto err; |
|
1042 |
result= find_set(typelib, str, length, NULL, |
|
1043 |
&error, &error_len, ¬_used); |
|
1044 |
if (error_len) |
|
1045 |
{
|
|
1067.4.16
by Nathan Williams
Fixed a few more system dependent type errors (size_t vs unsigned vs long unsigned). |
1046 |
length= min((uint32_t)sizeof(buff), error_len); |
629.5.2
by Toru Maesaka
Second pass of replacing MySQL's strmake() with libc calls |
1047 |
strncpy(buff, error, length); |
1048 |
buff[length]= '\0'; |
|
1
by brian
clean slate |
1049 |
strvalue= buff; |
1050 |
goto err; |
|
1051 |
}
|
|
1052 |
}
|
|
1053 |
else
|
|
1054 |
{
|
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
1055 |
if (value->val_int(value, (int64_t *)&result)) |
1
by brian
clean slate |
1056 |
goto err; |
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
1057 |
if (unlikely((result >= (1UL << typelib->count)) && |
1
by brian
clean slate |
1058 |
(typelib->count < sizeof(long)*8))) |
1059 |
{
|
|
1060 |
llstr(result, buff); |
|
1061 |
strvalue= buff; |
|
1062 |
goto err; |
|
1063 |
}
|
|
1064 |
}
|
|
151
by Brian Aker
Ulonglong to uint64_t |
1065 |
*(uint64_t*)save= result; |
1
by brian
clean slate |
1066 |
return 0; |
1067 |
err: |
|
1068 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->name, strvalue); |
|
1069 |
return 1; |
|
1070 |
}
|
|
1071 |
||
1072 |
||
654
by Brian Aker
Remove unused (yet more) |
1073 |
static void update_func_bool(Session *, struct st_mysql_sys_var *, |
1
by brian
clean slate |
1074 |
void *tgt, const void *save) |
1075 |
{
|
|
199
by Brian Aker
my_bool... |
1076 |
*(bool *) tgt= *(int *) save ? 1 : 0; |
1
by brian
clean slate |
1077 |
}
|
1078 |
||
1079 |
||
654
by Brian Aker
Remove unused (yet more) |
1080 |
static void update_func_int(Session *, struct st_mysql_sys_var *, |
1
by brian
clean slate |
1081 |
void *tgt, const void *save) |
1082 |
{
|
|
1083 |
*(int *)tgt= *(int *) save; |
|
1084 |
}
|
|
1085 |
||
1086 |
||
654
by Brian Aker
Remove unused (yet more) |
1087 |
static void update_func_long(Session *, struct st_mysql_sys_var *, |
1
by brian
clean slate |
1088 |
void *tgt, const void *save) |
1089 |
{
|
|
1090 |
*(long *)tgt= *(long *) save; |
|
1091 |
}
|
|
1092 |
||
1093 |
||
654
by Brian Aker
Remove unused (yet more) |
1094 |
static void update_func_int64_t(Session *, struct st_mysql_sys_var *, |
77.1.46
by Monty Taylor
Finished the warnings work! |
1095 |
void *tgt, const void *save) |
1
by brian
clean slate |
1096 |
{
|
152
by Brian Aker
longlong replacement |
1097 |
*(int64_t *)tgt= *(uint64_t *) save; |
1
by brian
clean slate |
1098 |
}
|
1099 |
||
1100 |
||
654
by Brian Aker
Remove unused (yet more) |
1101 |
static void update_func_str(Session *, struct st_mysql_sys_var *var, |
1
by brian
clean slate |
1102 |
void *tgt, const void *save) |
1103 |
{
|
|
1104 |
char *old= *(char **) tgt; |
|
1105 |
*(char **)tgt= *(char **) save; |
|
1106 |
if (var->flags & PLUGIN_VAR_MEMALLOC) |
|
1107 |
{
|
|
656.1.19
by Monty Taylor
Removed my_strdup from drizzled/ |
1108 |
*(char **)tgt= strdup(*(char **) save); |
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
1109 |
free(old); |
656.1.52
by Monty Taylor
Added more return value checks. |
1110 |
/*
|
1111 |
* There isn't a _really_ good thing to do here until this whole set_var
|
|
1112 |
* mess gets redesigned
|
|
1113 |
*/
|
|
1114 |
if (tgt == NULL) |
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
1115 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Out of memory.")); |
656.1.52
by Monty Taylor
Added more return value checks. |
1116 |
|
1
by brian
clean slate |
1117 |
}
|
1118 |
}
|
|
1119 |
||
1120 |
||
1121 |
/****************************************************************************
|
|
1122 |
System Variables support
|
|
1123 |
****************************************************************************/
|
|
1124 |
||
1125 |
||
970.1.1
by Brian Aker
Removed dead passed variables. |
1126 |
sys_var *find_sys_var(Session *, const char *str, uint32_t length) |
1
by brian
clean slate |
1127 |
{
|
1128 |
sys_var *var; |
|
1129 |
sys_var_pluginvar *pi= NULL; |
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
1130 |
plugin::Handle *plugin; |
1
by brian
clean slate |
1131 |
|
658
by Brian Aker
Part removal of my_pthread.h |
1132 |
pthread_rwlock_rdlock(&LOCK_system_variables_hash); |
1
by brian
clean slate |
1133 |
if ((var= intern_find_sys_var(str, length, false)) && |
1134 |
(pi= var->cast_pluginvar())) |
|
1135 |
{
|
|
658
by Brian Aker
Part removal of my_pthread.h |
1136 |
pthread_rwlock_unlock(&LOCK_system_variables_hash); |
971.1.19
by Monty Taylor
Remove most of plugin_ref. Fix several leaks (where the malloc was happening but never freed). One step away from no more plugin_ref. Yippee. It's so much easier the second time you try to do this. |
1137 |
if (!(plugin= pi->plugin)) |
1
by brian
clean slate |
1138 |
var= NULL; /* failed to lock it, it must be uninstalling */ |
971.1.19
by Monty Taylor
Remove most of plugin_ref. Fix several leaks (where the malloc was happening but never freed). One step away from no more plugin_ref. Yippee. It's so much easier the second time you try to do this. |
1139 |
else if (plugin->isInited == false) |
1
by brian
clean slate |
1140 |
{
|
1141 |
var= NULL; |
|
1142 |
}
|
|
1143 |
}
|
|
1144 |
else
|
|
658
by Brian Aker
Part removal of my_pthread.h |
1145 |
pthread_rwlock_unlock(&LOCK_system_variables_hash); |
1
by brian
clean slate |
1146 |
|
1147 |
/*
|
|
1148 |
If the variable exists but the plugin it is associated with is not ready
|
|
1149 |
then the intern_plugin_lock did not raise an error, so we do it here.
|
|
1150 |
*/
|
|
1151 |
if (pi && !var) |
|
1152 |
my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), (char*) str); |
|
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
1153 |
return(var); |
1
by brian
clean slate |
1154 |
}
|
1155 |
||
1156 |
||
1157 |
/*
|
|
1158 |
called by register_var, construct_options and test_plugin_options.
|
|
1159 |
Returns the 'bookmark' for the named variable.
|
|
1160 |
LOCK_system_variables_hash should be at least read locked
|
|
1161 |
*/
|
|
138
by Brian Aker
Refactoring around sql_plugin. |
1162 |
static st_bookmark *find_bookmark(const char *plugin, const char *name, int flags) |
1
by brian
clean slate |
1163 |
{
|
1164 |
st_bookmark *result= NULL; |
|
482
by Brian Aker
Remove uint. |
1165 |
uint32_t namelen, length, pluginlen= 0; |
1
by brian
clean slate |
1166 |
char *varname, *p; |
1167 |
||
520.1.21
by Brian Aker
THD -> Session rename |
1168 |
if (!(flags & PLUGIN_VAR_SessionLOCAL)) |
1
by brian
clean slate |
1169 |
return NULL; |
1170 |
||
1171 |
namelen= strlen(name); |
|
1172 |
if (plugin) |
|
1173 |
pluginlen= strlen(plugin) + 1; |
|
1174 |
length= namelen + pluginlen + 2; |
|
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
1175 |
varname= (char*) malloc(length); |
1
by brian
clean slate |
1176 |
|
1177 |
if (plugin) |
|
1178 |
{
|
|
673.2.1
by Toru Maesaka
First pass of replacing MySQL's strxmov with libc alternatives |
1179 |
sprintf(varname+1,"%s_%s",plugin,name); |
1
by brian
clean slate |
1180 |
for (p= varname + 1; *p; p++) |
1181 |
if (*p == '-') |
|
1182 |
*p= '_'; |
|
1183 |
}
|
|
1184 |
else
|
|
1185 |
memcpy(varname + 1, name, namelen + 1); |
|
1186 |
||
1187 |
varname[0]= flags & PLUGIN_VAR_TYPEMASK; |
|
1188 |
||
1189 |
result= (st_bookmark*) hash_search(&bookmark_hash, |
|
481
by Brian Aker
Remove all of uchar. |
1190 |
(const unsigned char*) varname, length - 1); |
1
by brian
clean slate |
1191 |
|
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
1192 |
free(varname); |
1
by brian
clean slate |
1193 |
return result; |
1194 |
}
|
|
1195 |
||
1196 |
||
1197 |
/*
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1198 |
returns a bookmark for session-local variables, creating if neccessary.
|
1199 |
returns null for non session-local variables.
|
|
1
by brian
clean slate |
1200 |
Requires that a write lock is obtained on LOCK_system_variables_hash
|
1201 |
*/
|
|
1202 |
static st_bookmark *register_var(const char *plugin, const char *name, |
|
1203 |
int flags) |
|
1204 |
{
|
|
482
by Brian Aker
Remove uint. |
1205 |
uint32_t length= strlen(plugin) + strlen(name) + 3, size= 0, offset, new_size; |
1
by brian
clean slate |
1206 |
st_bookmark *result; |
1207 |
char *varname, *p; |
|
1208 |
||
520.1.21
by Brian Aker
THD -> Session rename |
1209 |
if (!(flags & PLUGIN_VAR_SessionLOCAL)) |
1
by brian
clean slate |
1210 |
return NULL; |
1211 |
||
1212 |
switch (flags & PLUGIN_VAR_TYPEMASK) { |
|
1213 |
case PLUGIN_VAR_BOOL: |
|
937.2.12
by Stewart Smith
ensure correct alignment of all plugin variables. Manifesting as innodb_mysql test failure with SIGBUS on Sparc |
1214 |
size= ALIGN_SIZE(sizeof(bool)); |
1
by brian
clean slate |
1215 |
break; |
1216 |
case PLUGIN_VAR_INT: |
|
937.2.12
by Stewart Smith
ensure correct alignment of all plugin variables. Manifesting as innodb_mysql test failure with SIGBUS on Sparc |
1217 |
size= ALIGN_SIZE(sizeof(int)); |
1
by brian
clean slate |
1218 |
break; |
1219 |
case PLUGIN_VAR_LONG: |
|
1220 |
case PLUGIN_VAR_ENUM: |
|
937.2.12
by Stewart Smith
ensure correct alignment of all plugin variables. Manifesting as innodb_mysql test failure with SIGBUS on Sparc |
1221 |
size= ALIGN_SIZE(sizeof(long)); |
1
by brian
clean slate |
1222 |
break; |
1223 |
case PLUGIN_VAR_LONGLONG: |
|
1224 |
case PLUGIN_VAR_SET: |
|
937.2.12
by Stewart Smith
ensure correct alignment of all plugin variables. Manifesting as innodb_mysql test failure with SIGBUS on Sparc |
1225 |
size= ALIGN_SIZE(sizeof(uint64_t)); |
1
by brian
clean slate |
1226 |
break; |
1227 |
case PLUGIN_VAR_STR: |
|
937.2.12
by Stewart Smith
ensure correct alignment of all plugin variables. Manifesting as innodb_mysql test failure with SIGBUS on Sparc |
1228 |
size= ALIGN_SIZE(sizeof(char*)); |
1
by brian
clean slate |
1229 |
break; |
1230 |
default: |
|
51.1.62
by Jay Pipes
Removed/replaced BUG symbols and standardized TRUE/FALSE |
1231 |
assert(0); |
1
by brian
clean slate |
1232 |
return NULL; |
1233 |
};
|
|
1234 |
||
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
1235 |
varname= ((char*) malloc(length)); |
673.2.1
by Toru Maesaka
First pass of replacing MySQL's strxmov with libc alternatives |
1236 |
sprintf(varname+1, "%s_%s", plugin, name); |
1
by brian
clean slate |
1237 |
for (p= varname + 1; *p; p++) |
1238 |
if (*p == '-') |
|
1239 |
*p= '_'; |
|
1240 |
||
1241 |
if (!(result= find_bookmark(NULL, varname + 1, flags))) |
|
1242 |
{
|
|
1243 |
result= (st_bookmark*) alloc_root(&plugin_mem_root, |
|
1244 |
sizeof(struct st_bookmark) + length-1); |
|
1245 |
varname[0]= flags & PLUGIN_VAR_TYPEMASK; |
|
1246 |
memcpy(result->key, varname, length); |
|
1247 |
result->name_len= length - 2; |
|
1248 |
result->offset= -1; |
|
1249 |
||
51.1.62
by Jay Pipes
Removed/replaced BUG symbols and standardized TRUE/FALSE |
1250 |
assert(size && !(size & (size-1))); /* must be power of 2 */ |
1
by brian
clean slate |
1251 |
|
1252 |
offset= global_system_variables.dynamic_variables_size; |
|
1253 |
offset= (offset + size - 1) & ~(size - 1); |
|
1254 |
result->offset= (int) offset; |
|
1255 |
||
1256 |
new_size= (offset + size + 63) & ~63; |
|
1257 |
||
1258 |
if (new_size > global_variables_dynamic_size) |
|
1259 |
{
|
|
656.1.46
by Monty Taylor
More malloc return cleanups. |
1260 |
char* tmpptr= NULL; |
1261 |
if (!(tmpptr= |
|
1262 |
(char *)realloc(global_system_variables.dynamic_variables_ptr, |
|
1263 |
new_size))) |
|
1264 |
return NULL; |
|
1265 |
global_system_variables.dynamic_variables_ptr= tmpptr; |
|
1266 |
tmpptr= NULL; |
|
1267 |
if (!(tmpptr= |
|
1268 |
(char *)realloc(max_system_variables.dynamic_variables_ptr, |
|
1269 |
new_size))) |
|
1270 |
return NULL; |
|
1271 |
max_system_variables.dynamic_variables_ptr= tmpptr; |
|
656.1.26
by Monty Taylor
Finally removed all of the my_malloc stuff. |
1272 |
|
1
by brian
clean slate |
1273 |
/*
|
1274 |
Clear the new variable value space. This is required for string
|
|
1275 |
variables. If their value is non-NULL, it must point to a valid
|
|
1276 |
string.
|
|
1277 |
*/
|
|
212.6.1
by Mats Kindahl
Replacing all bzero() calls with memset() calls and removing the bzero.c file. |
1278 |
memset(global_system_variables.dynamic_variables_ptr + |
1279 |
global_variables_dynamic_size, 0, |
|
1280 |
new_size - global_variables_dynamic_size); |
|
1281 |
memset(max_system_variables.dynamic_variables_ptr + |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1282 |
global_variables_dynamic_size, 0, |
212.6.1
by Mats Kindahl
Replacing all bzero() calls with memset() calls and removing the bzero.c file. |
1283 |
new_size - global_variables_dynamic_size); |
1
by brian
clean slate |
1284 |
global_variables_dynamic_size= new_size; |
1285 |
}
|
|
1286 |
||
1287 |
global_system_variables.dynamic_variables_head= offset; |
|
1288 |
max_system_variables.dynamic_variables_head= offset; |
|
1289 |
global_system_variables.dynamic_variables_size= offset + size; |
|
1290 |
max_system_variables.dynamic_variables_size= offset + size; |
|
1291 |
global_system_variables.dynamic_variables_version++; |
|
1292 |
max_system_variables.dynamic_variables_version++; |
|
1293 |
||
1294 |
result->version= global_system_variables.dynamic_variables_version; |
|
1295 |
||
1296 |
/* this should succeed because we have already checked if a dup exists */
|
|
481
by Brian Aker
Remove all of uchar. |
1297 |
if (my_hash_insert(&bookmark_hash, (unsigned char*) result)) |
1
by brian
clean slate |
1298 |
{
|
1299 |
fprintf(stderr, "failed to add placeholder to hash"); |
|
51.1.62
by Jay Pipes
Removed/replaced BUG symbols and standardized TRUE/FALSE |
1300 |
assert(0); |
1
by brian
clean slate |
1301 |
}
|
1302 |
}
|
|
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
1303 |
free(varname); |
1
by brian
clean slate |
1304 |
return result; |
1305 |
}
|
|
1306 |
||
1307 |
||
1308 |
/*
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1309 |
returns a pointer to the memory which holds the session-local variable or
|
1310 |
a pointer to the global variable if session==null.
|
|
1
by brian
clean slate |
1311 |
If required, will sync with global variables if the requested variable
|
1312 |
has not yet been allocated in the current thread.
|
|
1313 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1314 |
static unsigned char *intern_sys_var_ptr(Session* session, int offset, bool global_lock) |
1
by brian
clean slate |
1315 |
{
|
51.1.62
by Jay Pipes
Removed/replaced BUG symbols and standardized TRUE/FALSE |
1316 |
assert(offset >= 0); |
895
by Brian Aker
Completion (?) of uint conversion. |
1317 |
assert((uint32_t)offset <= global_system_variables.dynamic_variables_head); |
1
by brian
clean slate |
1318 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1319 |
if (!session) |
481
by Brian Aker
Remove all of uchar. |
1320 |
return (unsigned char*) global_system_variables.dynamic_variables_ptr + offset; |
1
by brian
clean slate |
1321 |
|
1322 |
/*
|
|
1323 |
dynamic_variables_head points to the largest valid offset
|
|
1324 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1325 |
if (!session->variables.dynamic_variables_ptr || |
895
by Brian Aker
Completion (?) of uint conversion. |
1326 |
(uint32_t)offset > session->variables.dynamic_variables_head) |
1
by brian
clean slate |
1327 |
{
|
482
by Brian Aker
Remove uint. |
1328 |
uint32_t idx; |
1
by brian
clean slate |
1329 |
|
658
by Brian Aker
Part removal of my_pthread.h |
1330 |
pthread_rwlock_rdlock(&LOCK_system_variables_hash); |
1
by brian
clean slate |
1331 |
|
656.1.46
by Monty Taylor
More malloc return cleanups. |
1332 |
char *tmpptr= NULL; |
1333 |
if (!(tmpptr= (char *)realloc(session->variables.dynamic_variables_ptr, |
|
1334 |
global_variables_dynamic_size))) |
|
1335 |
return NULL; |
|
1336 |
session->variables.dynamic_variables_ptr= tmpptr; |
|
1
by brian
clean slate |
1337 |
|
1338 |
if (global_lock) |
|
1339 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
1340 |
||
1341 |
safe_mutex_assert_owner(&LOCK_global_system_variables); |
|
1342 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1343 |
memcpy(session->variables.dynamic_variables_ptr + |
1344 |
session->variables.dynamic_variables_size, |
|
1
by brian
clean slate |
1345 |
global_system_variables.dynamic_variables_ptr + |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1346 |
session->variables.dynamic_variables_size, |
1
by brian
clean slate |
1347 |
global_system_variables.dynamic_variables_size - |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1348 |
session->variables.dynamic_variables_size); |
1
by brian
clean slate |
1349 |
|
1350 |
/*
|
|
1351 |
now we need to iterate through any newly copied 'defaults'
|
|
1352 |
and if it is a string type with MEMALLOC flag, we need to strdup
|
|
1353 |
*/
|
|
1354 |
for (idx= 0; idx < bookmark_hash.records; idx++) |
|
1355 |
{
|
|
1356 |
sys_var_pluginvar *pi; |
|
1357 |
sys_var *var; |
|
1358 |
st_bookmark *v= (st_bookmark*) hash_element(&bookmark_hash,idx); |
|
1359 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1360 |
if (v->version <= session->variables.dynamic_variables_version || |
1
by brian
clean slate |
1361 |
!(var= intern_find_sys_var(v->key + 1, v->name_len, true)) || |
1362 |
!(pi= var->cast_pluginvar()) || |
|
1363 |
v->key[0] != (pi->plugin_var->flags & PLUGIN_VAR_TYPEMASK)) |
|
1364 |
continue; |
|
1365 |
||
1366 |
/* Here we do anything special that may be required of the data types */
|
|
1367 |
||
1368 |
if ((pi->plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR && |
|
1369 |
pi->plugin_var->flags & PLUGIN_VAR_MEMALLOC) |
|
1370 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1371 |
char **pp= (char**) (session->variables.dynamic_variables_ptr + |
1
by brian
clean slate |
1372 |
*(int*)(pi->plugin_var + 1)); |
1373 |
if ((*pp= *(char**) (global_system_variables.dynamic_variables_ptr + |
|
1374 |
*(int*)(pi->plugin_var + 1)))) |
|
656.1.19
by Monty Taylor
Removed my_strdup from drizzled/ |
1375 |
*pp= strdup(*pp); |
656.1.52
by Monty Taylor
Added more return value checks. |
1376 |
if (*pp == NULL) |
1377 |
return NULL; |
|
1
by brian
clean slate |
1378 |
}
|
1379 |
}
|
|
1380 |
||
1381 |
if (global_lock) |
|
1382 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1383 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1384 |
session->variables.dynamic_variables_version= |
1
by brian
clean slate |
1385 |
global_system_variables.dynamic_variables_version; |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1386 |
session->variables.dynamic_variables_head= |
1
by brian
clean slate |
1387 |
global_system_variables.dynamic_variables_head; |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1388 |
session->variables.dynamic_variables_size= |
1
by brian
clean slate |
1389 |
global_system_variables.dynamic_variables_size; |
1390 |
||
658
by Brian Aker
Part removal of my_pthread.h |
1391 |
pthread_rwlock_unlock(&LOCK_system_variables_hash); |
1
by brian
clean slate |
1392 |
}
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1393 |
return (unsigned char*)session->variables.dynamic_variables_ptr + offset; |
1394 |
}
|
|
1395 |
||
1396 |
static bool *mysql_sys_var_ptr_bool(Session* a_session, int offset) |
|
1397 |
{
|
|
1398 |
return (bool *)intern_sys_var_ptr(a_session, offset, true); |
|
1399 |
}
|
|
1400 |
||
1401 |
static int *mysql_sys_var_ptr_int(Session* a_session, int offset) |
|
1402 |
{
|
|
1403 |
return (int *)intern_sys_var_ptr(a_session, offset, true); |
|
1404 |
}
|
|
1405 |
||
1406 |
static long *mysql_sys_var_ptr_long(Session* a_session, int offset) |
|
1407 |
{
|
|
1408 |
return (long *)intern_sys_var_ptr(a_session, offset, true); |
|
1409 |
}
|
|
1410 |
||
1411 |
static int64_t *mysql_sys_var_ptr_int64_t(Session* a_session, int offset) |
|
1412 |
{
|
|
1413 |
return (int64_t *)intern_sys_var_ptr(a_session, offset, true); |
|
1414 |
}
|
|
1415 |
||
1416 |
static char **mysql_sys_var_ptr_str(Session* a_session, int offset) |
|
1417 |
{
|
|
1418 |
return (char **)intern_sys_var_ptr(a_session, offset, true); |
|
1419 |
}
|
|
1420 |
||
1421 |
static uint64_t *mysql_sys_var_ptr_set(Session* a_session, int offset) |
|
1422 |
{
|
|
1423 |
return (uint64_t *)intern_sys_var_ptr(a_session, offset, true); |
|
1424 |
}
|
|
1425 |
||
1426 |
static unsigned long *mysql_sys_var_ptr_enum(Session* a_session, int offset) |
|
1427 |
{
|
|
1428 |
return (unsigned long *)intern_sys_var_ptr(a_session, offset, true); |
|
1429 |
}
|
|
1430 |
||
1431 |
||
1432 |
void plugin_sessionvar_init(Session *session) |
|
1433 |
{
|
|
971.1.21
by Monty Taylor
Store StorageEngine in system variables, rather than storage engine plugin. |
1434 |
session->variables.storage_engine= NULL; |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1435 |
cleanup_variables(session, &session->variables); |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1436 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1437 |
session->variables= global_system_variables; |
971.1.21
by Monty Taylor
Store StorageEngine in system variables, rather than storage engine plugin. |
1438 |
session->variables.storage_engine= NULL; |
1
by brian
clean slate |
1439 |
|
1440 |
/* we are going to allocate these lazily */
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1441 |
session->variables.dynamic_variables_version= 0; |
1442 |
session->variables.dynamic_variables_size= 0; |
|
1443 |
session->variables.dynamic_variables_ptr= 0; |
|
1
by brian
clean slate |
1444 |
|
971.1.21
by Monty Taylor
Store StorageEngine in system variables, rather than storage engine plugin. |
1445 |
session->variables.storage_engine= global_system_variables.storage_engine; |
1
by brian
clean slate |
1446 |
}
|
1447 |
||
1448 |
||
1449 |
/*
|
|
1450 |
Unlocks all system variables which hold a reference
|
|
1451 |
*/
|
|
654
by Brian Aker
Remove unused (yet more) |
1452 |
static void unlock_variables(Session *, struct system_variables *vars) |
1
by brian
clean slate |
1453 |
{
|
971.1.21
by Monty Taylor
Store StorageEngine in system variables, rather than storage engine plugin. |
1454 |
vars->storage_engine= NULL; |
1
by brian
clean slate |
1455 |
}
|
1456 |
||
1457 |
||
1458 |
/*
|
|
1459 |
Frees memory used by system variables
|
|
1460 |
||
1461 |
Unlike plugin_vars_free_values() it frees all variables of all plugins,
|
|
1462 |
it's used on shutdown.
|
|
1463 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1464 |
static void cleanup_variables(Session *session, struct system_variables *vars) |
1
by brian
clean slate |
1465 |
{
|
1466 |
st_bookmark *v; |
|
1467 |
sys_var_pluginvar *pivar; |
|
1468 |
sys_var *var; |
|
1469 |
int flags; |
|
482
by Brian Aker
Remove uint. |
1470 |
uint32_t idx; |
1
by brian
clean slate |
1471 |
|
658
by Brian Aker
Part removal of my_pthread.h |
1472 |
pthread_rwlock_rdlock(&LOCK_system_variables_hash); |
1
by brian
clean slate |
1473 |
for (idx= 0; idx < bookmark_hash.records; idx++) |
1474 |
{
|
|
1475 |
v= (st_bookmark*) hash_element(&bookmark_hash, idx); |
|
1476 |
if (v->version > vars->dynamic_variables_version || |
|
1477 |
!(var= intern_find_sys_var(v->key + 1, v->name_len, true)) || |
|
1478 |
!(pivar= var->cast_pluginvar()) || |
|
1479 |
v->key[0] != (pivar->plugin_var->flags & PLUGIN_VAR_TYPEMASK)) |
|
1480 |
continue; |
|
1481 |
||
1482 |
flags= pivar->plugin_var->flags; |
|
1483 |
||
1484 |
if ((flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR && |
|
520.1.21
by Brian Aker
THD -> Session rename |
1485 |
flags & PLUGIN_VAR_SessionLOCAL && flags & PLUGIN_VAR_MEMALLOC) |
1
by brian
clean slate |
1486 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1487 |
char **ptr= (char**) pivar->real_value_ptr(session, OPT_SESSION); |
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
1488 |
free(*ptr); |
1
by brian
clean slate |
1489 |
*ptr= NULL; |
1490 |
}
|
|
1491 |
}
|
|
658
by Brian Aker
Part removal of my_pthread.h |
1492 |
pthread_rwlock_unlock(&LOCK_system_variables_hash); |
1
by brian
clean slate |
1493 |
|
971.1.21
by Monty Taylor
Store StorageEngine in system variables, rather than storage engine plugin. |
1494 |
assert(vars->storage_engine == NULL); |
1
by brian
clean slate |
1495 |
|
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
1496 |
free(vars->dynamic_variables_ptr); |
1
by brian
clean slate |
1497 |
vars->dynamic_variables_ptr= NULL; |
1498 |
vars->dynamic_variables_size= 0; |
|
1499 |
vars->dynamic_variables_version= 0; |
|
1500 |
}
|
|
1501 |
||
1502 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1503 |
void plugin_sessionvar_cleanup(Session *session) |
1
by brian
clean slate |
1504 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1505 |
unlock_variables(session, &session->variables); |
1506 |
cleanup_variables(session, &session->variables); |
|
1
by brian
clean slate |
1507 |
}
|
1508 |
||
1509 |
||
1510 |
/**
|
|
1511 |
@brief Free values of thread variables of a plugin.
|
|
1512 |
||
1513 |
This must be called before a plugin is deleted. Otherwise its
|
|
1514 |
variables are no longer accessible and the value space is lost. Note
|
|
1515 |
that only string values with PLUGIN_VAR_MEMALLOC are allocated and
|
|
1516 |
must be freed.
|
|
1517 |
||
1518 |
@param[in] vars Chain of system variables of a plugin
|
|
1519 |
*/
|
|
1520 |
||
1521 |
static void plugin_vars_free_values(sys_var *vars) |
|
1522 |
{
|
|
1523 |
||
1055.2.20
by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters. |
1524 |
for (sys_var *var= vars; var; var= var->getNext()) |
1
by brian
clean slate |
1525 |
{
|
1526 |
sys_var_pluginvar *piv= var->cast_pluginvar(); |
|
1527 |
if (piv && |
|
1528 |
((piv->plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR) && |
|
1529 |
(piv->plugin_var->flags & PLUGIN_VAR_MEMALLOC)) |
|
1530 |
{
|
|
1531 |
/* Free the string from global_system_variables. */
|
|
1532 |
char **valptr= (char**) piv->real_value_ptr(NULL, OPT_GLOBAL); |
|
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
1533 |
free(*valptr); |
1
by brian
clean slate |
1534 |
*valptr= NULL; |
1535 |
}
|
|
1536 |
}
|
|
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
1537 |
return; |
1
by brian
clean slate |
1538 |
}
|
1539 |
||
1540 |
||
1541 |
bool sys_var_pluginvar::check_update_type(Item_result type) |
|
1542 |
{
|
|
1543 |
if (is_readonly()) |
|
1544 |
return 1; |
|
1545 |
switch (plugin_var->flags & PLUGIN_VAR_TYPEMASK) { |
|
1546 |
case PLUGIN_VAR_INT: |
|
1547 |
case PLUGIN_VAR_LONG: |
|
1548 |
case PLUGIN_VAR_LONGLONG: |
|
1549 |
return type != INT_RESULT; |
|
1550 |
case PLUGIN_VAR_STR: |
|
1551 |
return type != STRING_RESULT; |
|
1552 |
default: |
|
1553 |
return 0; |
|
1554 |
}
|
|
1555 |
}
|
|
1556 |
||
1557 |
||
1558 |
SHOW_TYPE sys_var_pluginvar::show_type() |
|
1559 |
{
|
|
1560 |
switch (plugin_var->flags & PLUGIN_VAR_TYPEMASK) { |
|
1561 |
case PLUGIN_VAR_BOOL: |
|
1562 |
return SHOW_MY_BOOL; |
|
1563 |
case PLUGIN_VAR_INT: |
|
1564 |
return SHOW_INT; |
|
1565 |
case PLUGIN_VAR_LONG: |
|
1566 |
return SHOW_LONG; |
|
1567 |
case PLUGIN_VAR_LONGLONG: |
|
1568 |
return SHOW_LONGLONG; |
|
1569 |
case PLUGIN_VAR_STR: |
|
1570 |
return SHOW_CHAR_PTR; |
|
1571 |
case PLUGIN_VAR_ENUM: |
|
1572 |
case PLUGIN_VAR_SET: |
|
1573 |
return SHOW_CHAR; |
|
1574 |
default: |
|
51.1.62
by Jay Pipes
Removed/replaced BUG symbols and standardized TRUE/FALSE |
1575 |
assert(0); |
1
by brian
clean slate |
1576 |
return SHOW_UNDEF; |
1577 |
}
|
|
1578 |
}
|
|
1579 |
||
1580 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1581 |
unsigned char* sys_var_pluginvar::real_value_ptr(Session *session, enum_var_type type) |
1
by brian
clean slate |
1582 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1583 |
assert(session || (type == OPT_GLOBAL)); |
520.1.21
by Brian Aker
THD -> Session rename |
1584 |
if (plugin_var->flags & PLUGIN_VAR_SessionLOCAL) |
1
by brian
clean slate |
1585 |
{
|
1586 |
if (type == OPT_GLOBAL) |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1587 |
session= NULL; |
1
by brian
clean slate |
1588 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1589 |
return intern_sys_var_ptr(session, *(int*) (plugin_var+1), false); |
1
by brian
clean slate |
1590 |
}
|
481
by Brian Aker
Remove all of uchar. |
1591 |
return *(unsigned char**) (plugin_var+1); |
1
by brian
clean slate |
1592 |
}
|
1593 |
||
1594 |
||
1595 |
TYPELIB* sys_var_pluginvar::plugin_var_typelib(void) |
|
1596 |
{
|
|
520.1.21
by Brian Aker
THD -> Session rename |
1597 |
switch (plugin_var->flags & (PLUGIN_VAR_TYPEMASK | PLUGIN_VAR_SessionLOCAL)) { |
1
by brian
clean slate |
1598 |
case PLUGIN_VAR_ENUM: |
1599 |
return ((sysvar_enum_t *)plugin_var)->typelib; |
|
1600 |
case PLUGIN_VAR_SET: |
|
1601 |
return ((sysvar_set_t *)plugin_var)->typelib; |
|
520.1.21
by Brian Aker
THD -> Session rename |
1602 |
case PLUGIN_VAR_ENUM | PLUGIN_VAR_SessionLOCAL: |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1603 |
return ((sessionvar_enum_t *)plugin_var)->typelib; |
520.1.21
by Brian Aker
THD -> Session rename |
1604 |
case PLUGIN_VAR_SET | PLUGIN_VAR_SessionLOCAL: |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1605 |
return ((sessionvar_set_t *)plugin_var)->typelib; |
1
by brian
clean slate |
1606 |
default: |
1607 |
return NULL; |
|
1608 |
}
|
|
1609 |
return NULL; |
|
1610 |
}
|
|
1611 |
||
1612 |
||
779.3.10
by Monty Taylor
Turned on -Wshadow. |
1613 |
unsigned char* sys_var_pluginvar::value_ptr(Session *session, enum_var_type type, const LEX_STRING *) |
1
by brian
clean slate |
1614 |
{
|
481
by Brian Aker
Remove all of uchar. |
1615 |
unsigned char* result; |
1
by brian
clean slate |
1616 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1617 |
result= real_value_ptr(session, type); |
1
by brian
clean slate |
1618 |
|
1619 |
if ((plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_ENUM) |
|
481
by Brian Aker
Remove all of uchar. |
1620 |
result= (unsigned char*) get_type(plugin_var_typelib(), *(ulong*)result); |
1
by brian
clean slate |
1621 |
else if ((plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_SET) |
1622 |
{
|
|
1623 |
char buffer[STRING_BUFFER_USUAL_SIZE]; |
|
1624 |
String str(buffer, sizeof(buffer), system_charset_info); |
|
1625 |
TYPELIB *typelib= plugin_var_typelib(); |
|
151
by Brian Aker
Ulonglong to uint64_t |
1626 |
uint64_t mask= 1, value= *(uint64_t*) result; |
482
by Brian Aker
Remove uint. |
1627 |
uint32_t i; |
1
by brian
clean slate |
1628 |
|
1629 |
str.length(0); |
|
1630 |
for (i= 0; i < typelib->count; i++, mask<<=1) |
|
1631 |
{
|
|
1632 |
if (!(value & mask)) |
|
1633 |
continue; |
|
1634 |
str.append(typelib->type_names[i], typelib->type_lengths[i]); |
|
1635 |
str.append(','); |
|
1636 |
}
|
|
1637 |
||
481
by Brian Aker
Remove all of uchar. |
1638 |
result= (unsigned char*) ""; |
1
by brian
clean slate |
1639 |
if (str.length()) |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1640 |
result= (unsigned char*) session->strmake(str.ptr(), str.length()-1); |
1
by brian
clean slate |
1641 |
}
|
1642 |
return result; |
|
1643 |
}
|
|
1644 |
||
1645 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1646 |
bool sys_var_pluginvar::check(Session *session, set_var *var) |
1
by brian
clean slate |
1647 |
{
|
1648 |
st_item_value_holder value; |
|
51.1.62
by Jay Pipes
Removed/replaced BUG symbols and standardized TRUE/FALSE |
1649 |
assert(is_readonly() || plugin_var->check); |
1
by brian
clean slate |
1650 |
|
1651 |
value.value_type= item_value_type; |
|
1652 |
value.val_str= item_val_str; |
|
1653 |
value.val_int= item_val_int; |
|
1654 |
value.val_real= item_val_real; |
|
1655 |
value.item= var->value; |
|
1656 |
||
1657 |
return is_readonly() || |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1658 |
plugin_var->check(session, plugin_var, &var->save_result, &value); |
1
by brian
clean slate |
1659 |
}
|
1660 |
||
1661 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1662 |
void sys_var_pluginvar::set_default(Session *session, enum_var_type type) |
1
by brian
clean slate |
1663 |
{
|
1664 |
const void *src; |
|
1665 |
void *tgt; |
|
1666 |
||
51.1.62
by Jay Pipes
Removed/replaced BUG symbols and standardized TRUE/FALSE |
1667 |
assert(is_readonly() || plugin_var->update); |
1
by brian
clean slate |
1668 |
|
1669 |
if (is_readonly()) |
|
1670 |
return; |
|
1671 |
||
1672 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1673 |
tgt= real_value_ptr(session, type); |
1
by brian
clean slate |
1674 |
src= ((void **) (plugin_var + 1) + 1); |
1675 |
||
520.1.21
by Brian Aker
THD -> Session rename |
1676 |
if (plugin_var->flags & PLUGIN_VAR_SessionLOCAL) |
1
by brian
clean slate |
1677 |
{
|
1678 |
if (type != OPT_GLOBAL) |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1679 |
src= real_value_ptr(session, OPT_GLOBAL); |
1
by brian
clean slate |
1680 |
else
|
1681 |
switch (plugin_var->flags & PLUGIN_VAR_TYPEMASK) { |
|
1682 |
case PLUGIN_VAR_INT: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1683 |
src= &((sessionvar_uint_t*) plugin_var)->def_val; |
1
by brian
clean slate |
1684 |
break; |
1685 |
case PLUGIN_VAR_LONG: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1686 |
src= &((sessionvar_ulong_t*) plugin_var)->def_val; |
1
by brian
clean slate |
1687 |
break; |
1688 |
case PLUGIN_VAR_LONGLONG: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1689 |
src= &((sessionvar_uint64_t_t*) plugin_var)->def_val; |
1
by brian
clean slate |
1690 |
break; |
1691 |
case PLUGIN_VAR_ENUM: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1692 |
src= &((sessionvar_enum_t*) plugin_var)->def_val; |
1
by brian
clean slate |
1693 |
break; |
1694 |
case PLUGIN_VAR_SET: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1695 |
src= &((sessionvar_set_t*) plugin_var)->def_val; |
1
by brian
clean slate |
1696 |
break; |
1697 |
case PLUGIN_VAR_BOOL: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1698 |
src= &((sessionvar_bool_t*) plugin_var)->def_val; |
1
by brian
clean slate |
1699 |
break; |
1700 |
case PLUGIN_VAR_STR: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1701 |
src= &((sessionvar_str_t*) plugin_var)->def_val; |
1
by brian
clean slate |
1702 |
break; |
1703 |
default: |
|
51.1.62
by Jay Pipes
Removed/replaced BUG symbols and standardized TRUE/FALSE |
1704 |
assert(0); |
1
by brian
clean slate |
1705 |
}
|
1706 |
}
|
|
1707 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1708 |
/* session must equal current_session if PLUGIN_VAR_SessionLOCAL flag is set */
|
520.1.21
by Brian Aker
THD -> Session rename |
1709 |
assert(!(plugin_var->flags & PLUGIN_VAR_SessionLOCAL) || |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1710 |
session == current_session); |
1
by brian
clean slate |
1711 |
|
520.1.21
by Brian Aker
THD -> Session rename |
1712 |
if (!(plugin_var->flags & PLUGIN_VAR_SessionLOCAL) || type == OPT_GLOBAL) |
1
by brian
clean slate |
1713 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1714 |
plugin_var->update(session, plugin_var, tgt, src); |
1
by brian
clean slate |
1715 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
1716 |
}
|
|
1717 |
else
|
|
1718 |
{
|
|
1719 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1720 |
plugin_var->update(session, plugin_var, tgt, src); |
1
by brian
clean slate |
1721 |
}
|
1722 |
}
|
|
1723 |
||
1724 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1725 |
bool sys_var_pluginvar::update(Session *session, set_var *var) |
1
by brian
clean slate |
1726 |
{
|
1727 |
void *tgt; |
|
1728 |
||
51.1.62
by Jay Pipes
Removed/replaced BUG symbols and standardized TRUE/FALSE |
1729 |
assert(is_readonly() || plugin_var->update); |
1
by brian
clean slate |
1730 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1731 |
/* session must equal current_session if PLUGIN_VAR_SessionLOCAL flag is set */
|
520.1.21
by Brian Aker
THD -> Session rename |
1732 |
assert(!(plugin_var->flags & PLUGIN_VAR_SessionLOCAL) || |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1733 |
session == current_session); |
1
by brian
clean slate |
1734 |
|
1735 |
if (is_readonly()) |
|
1736 |
return 1; |
|
1737 |
||
1738 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1739 |
tgt= real_value_ptr(session, var->type); |
1
by brian
clean slate |
1740 |
|
520.1.21
by Brian Aker
THD -> Session rename |
1741 |
if (!(plugin_var->flags & PLUGIN_VAR_SessionLOCAL) || var->type == OPT_GLOBAL) |
1
by brian
clean slate |
1742 |
{
|
1743 |
/* variable we are updating has global scope, so we unlock after updating */
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1744 |
plugin_var->update(session, plugin_var, tgt, &var->save_result); |
1
by brian
clean slate |
1745 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
1746 |
}
|
|
1747 |
else
|
|
1748 |
{
|
|
1749 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1750 |
plugin_var->update(session, plugin_var, tgt, &var->save_result); |
1
by brian
clean slate |
1751 |
}
|
1752 |
return 0; |
|
1753 |
}
|
|
1754 |
||
1755 |
||
1756 |
#define OPTION_SET_LIMITS(type, options, opt) \
|
|
322.2.2
by Mats Kindahl
Hiding THD::proc_info field and providing a setter and getter. |
1757 |
options->var_type= type; \
|
1758 |
options->def_value= (opt)->def_val; \
|
|
1759 |
options->min_value= (opt)->min_val; \
|
|
1760 |
options->max_value= (opt)->max_val; \
|
|
1
by brian
clean slate |
1761 |
options->block_size= (long) (opt)->blk_sz
|
1762 |
||
1763 |
||
1764 |
static void plugin_opt_set_limits(struct my_option *options, |
|
1765 |
const struct st_mysql_sys_var *opt) |
|
1766 |
{
|
|
1767 |
options->sub_size= 0; |
|
1768 |
||
1769 |
switch (opt->flags & (PLUGIN_VAR_TYPEMASK | |
|
520.1.21
by Brian Aker
THD -> Session rename |
1770 |
PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_SessionLOCAL)) { |
1
by brian
clean slate |
1771 |
/* global system variables */
|
1772 |
case PLUGIN_VAR_INT: |
|
1773 |
OPTION_SET_LIMITS(GET_INT, options, (sysvar_int_t*) opt); |
|
1774 |
break; |
|
1775 |
case PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED: |
|
1776 |
OPTION_SET_LIMITS(GET_UINT, options, (sysvar_uint_t*) opt); |
|
1777 |
break; |
|
1778 |
case PLUGIN_VAR_LONG: |
|
1779 |
OPTION_SET_LIMITS(GET_LONG, options, (sysvar_long_t*) opt); |
|
1780 |
break; |
|
1781 |
case PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED: |
|
896.4.16
by Stewart Smith
for getopt, replace GET_ULONG with GET_UINT32. |
1782 |
OPTION_SET_LIMITS(GET_ULONG_IS_FAIL, options, (sysvar_ulong_t*) opt); |
1
by brian
clean slate |
1783 |
break; |
1784 |
case PLUGIN_VAR_LONGLONG: |
|
152
by Brian Aker
longlong replacement |
1785 |
OPTION_SET_LIMITS(GET_LL, options, (sysvar_int64_t_t*) opt); |
1
by brian
clean slate |
1786 |
break; |
1787 |
case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED: |
|
151
by Brian Aker
Ulonglong to uint64_t |
1788 |
OPTION_SET_LIMITS(GET_ULL, options, (sysvar_uint64_t_t*) opt); |
1
by brian
clean slate |
1789 |
break; |
1790 |
case PLUGIN_VAR_ENUM: |
|
1791 |
options->var_type= GET_ENUM; |
|
1792 |
options->typelib= ((sysvar_enum_t*) opt)->typelib; |
|
1793 |
options->def_value= ((sysvar_enum_t*) opt)->def_val; |
|
1794 |
options->min_value= options->block_size= 0; |
|
1795 |
options->max_value= options->typelib->count - 1; |
|
1796 |
break; |
|
1797 |
case PLUGIN_VAR_SET: |
|
1798 |
options->var_type= GET_SET; |
|
1799 |
options->typelib= ((sysvar_set_t*) opt)->typelib; |
|
1800 |
options->def_value= ((sysvar_set_t*) opt)->def_val; |
|
1801 |
options->min_value= options->block_size= 0; |
|
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
1802 |
options->max_value= (1UL << options->typelib->count) - 1; |
1
by brian
clean slate |
1803 |
break; |
1804 |
case PLUGIN_VAR_BOOL: |
|
1805 |
options->var_type= GET_BOOL; |
|
1806 |
options->def_value= ((sysvar_bool_t*) opt)->def_val; |
|
1807 |
break; |
|
1808 |
case PLUGIN_VAR_STR: |
|
1809 |
options->var_type= ((opt->flags & PLUGIN_VAR_MEMALLOC) ? |
|
1810 |
GET_STR_ALLOC : GET_STR); |
|
157
by Brian Aker
Second pass cleanup on removal of my_uint types |
1811 |
options->def_value= (intptr_t) ((sysvar_str_t*) opt)->def_val; |
1
by brian
clean slate |
1812 |
break; |
1813 |
/* threadlocal variables */
|
|
520.1.21
by Brian Aker
THD -> Session rename |
1814 |
case PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL: |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1815 |
OPTION_SET_LIMITS(GET_INT, options, (sessionvar_int_t*) opt); |
1
by brian
clean slate |
1816 |
break; |
520.1.21
by Brian Aker
THD -> Session rename |
1817 |
case PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_SessionLOCAL: |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1818 |
OPTION_SET_LIMITS(GET_UINT, options, (sessionvar_uint_t*) opt); |
1
by brian
clean slate |
1819 |
break; |
520.1.21
by Brian Aker
THD -> Session rename |
1820 |
case PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL: |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1821 |
OPTION_SET_LIMITS(GET_LONG, options, (sessionvar_long_t*) opt); |
1
by brian
clean slate |
1822 |
break; |
520.1.21
by Brian Aker
THD -> Session rename |
1823 |
case PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_SessionLOCAL: |
896.4.16
by Stewart Smith
for getopt, replace GET_ULONG with GET_UINT32. |
1824 |
OPTION_SET_LIMITS(GET_ULONG_IS_FAIL, options, (sessionvar_ulong_t*) opt); |
1
by brian
clean slate |
1825 |
break; |
520.1.21
by Brian Aker
THD -> Session rename |
1826 |
case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL: |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1827 |
OPTION_SET_LIMITS(GET_LL, options, (sessionvar_int64_t_t*) opt); |
1
by brian
clean slate |
1828 |
break; |
520.1.21
by Brian Aker
THD -> Session rename |
1829 |
case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_SessionLOCAL: |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1830 |
OPTION_SET_LIMITS(GET_ULL, options, (sessionvar_uint64_t_t*) opt); |
1
by brian
clean slate |
1831 |
break; |
520.1.21
by Brian Aker
THD -> Session rename |
1832 |
case PLUGIN_VAR_ENUM | PLUGIN_VAR_SessionLOCAL: |
1
by brian
clean slate |
1833 |
options->var_type= GET_ENUM; |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1834 |
options->typelib= ((sessionvar_enum_t*) opt)->typelib; |
1835 |
options->def_value= ((sessionvar_enum_t*) opt)->def_val; |
|
1
by brian
clean slate |
1836 |
options->min_value= options->block_size= 0; |
1837 |
options->max_value= options->typelib->count - 1; |
|
1838 |
break; |
|
520.1.21
by Brian Aker
THD -> Session rename |
1839 |
case PLUGIN_VAR_SET | PLUGIN_VAR_SessionLOCAL: |
1
by brian
clean slate |
1840 |
options->var_type= GET_SET; |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1841 |
options->typelib= ((sessionvar_set_t*) opt)->typelib; |
1842 |
options->def_value= ((sessionvar_set_t*) opt)->def_val; |
|
1
by brian
clean slate |
1843 |
options->min_value= options->block_size= 0; |
398.1.8
by Monty Taylor
Enabled -Wlong-long. |
1844 |
options->max_value= (1UL << options->typelib->count) - 1; |
1
by brian
clean slate |
1845 |
break; |
520.1.21
by Brian Aker
THD -> Session rename |
1846 |
case PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL: |
1
by brian
clean slate |
1847 |
options->var_type= GET_BOOL; |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1848 |
options->def_value= ((sessionvar_bool_t*) opt)->def_val; |
1
by brian
clean slate |
1849 |
break; |
520.1.21
by Brian Aker
THD -> Session rename |
1850 |
case PLUGIN_VAR_STR | PLUGIN_VAR_SessionLOCAL: |
1
by brian
clean slate |
1851 |
options->var_type= ((opt->flags & PLUGIN_VAR_MEMALLOC) ? |
1852 |
GET_STR_ALLOC : GET_STR); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1853 |
options->def_value= (intptr_t) ((sessionvar_str_t*) opt)->def_val; |
1
by brian
clean slate |
1854 |
break; |
1855 |
default: |
|
51.1.62
by Jay Pipes
Removed/replaced BUG symbols and standardized TRUE/FALSE |
1856 |
assert(0); |
1
by brian
clean slate |
1857 |
}
|
1858 |
options->arg_type= REQUIRED_ARG; |
|
1859 |
if (opt->flags & PLUGIN_VAR_NOCMDARG) |
|
1860 |
options->arg_type= NO_ARG; |
|
1861 |
if (opt->flags & PLUGIN_VAR_OPCMDARG) |
|
1862 |
options->arg_type= OPT_ARG; |
|
1863 |
}
|
|
1864 |
||
143
by Brian Aker
Bool cleanup. |
1865 |
extern "C" bool get_one_plugin_option(int optid, const struct my_option *, |
1
by brian
clean slate |
1866 |
char *); |
1867 |
||
654
by Brian Aker
Remove unused (yet more) |
1868 |
bool get_one_plugin_option(int, const struct my_option *, char *) |
1
by brian
clean slate |
1869 |
{
|
1870 |
return 0; |
|
1871 |
}
|
|
1872 |
||
1873 |
||
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
1874 |
static int construct_options(MEM_ROOT *mem_root, plugin::Handle *tmp, |
138
by Brian Aker
Refactoring around sql_plugin. |
1875 |
my_option *options, bool can_disable) |
1
by brian
clean slate |
1876 |
{
|
1093.3.4
by Monty Taylor
Naming cleanups. |
1877 |
const char *plugin_name= tmp->getManifest().name; |
482
by Brian Aker
Remove uint. |
1878 |
uint32_t namelen= strlen(plugin_name), optnamelen; |
1879 |
uint32_t buffer_length= namelen * 4 + (can_disable ? 75 : 10); |
|
1119.6.1
by Stewart Smith
remove nasty malloc() optimisation in --help plugin for sql_plugin. Also document the general turdiness of this area of code. |
1880 |
char *name= (char*) alloc_root(mem_root, buffer_length); |
1881 |
bool *enabled_value= (bool*) alloc_root(mem_root, sizeof(bool)); |
|
1
by brian
clean slate |
1882 |
char *optname, *p; |
1883 |
int index= 0, offset= 0; |
|
1884 |
st_mysql_sys_var *opt, **plugin_option; |
|
1885 |
st_bookmark *v; |
|
1886 |
||
1887 |
/* support --skip-plugin-foo syntax */
|
|
1888 |
memcpy(name, plugin_name, namelen + 1); |
|
383.1.12
by Brian Aker
Much closer toward UTF8 being around all the time... |
1889 |
my_casedn_str(&my_charset_utf8_general_ci, name); |
673.2.1
by Toru Maesaka
First pass of replacing MySQL's strxmov with libc alternatives |
1890 |
sprintf(name+namelen+1, "plugin-%s", name); |
1
by brian
clean slate |
1891 |
/* Now we have namelen + 1 + 7 + namelen + 1 == namelen * 2 + 9. */
|
1892 |
||
1893 |
for (p= name + namelen*2 + 8; p > name; p--) |
|
1894 |
if (*p == '_') |
|
1895 |
*p= '-'; |
|
1896 |
||
1897 |
if (can_disable) |
|
1898 |
{
|
|
673.2.1
by Toru Maesaka
First pass of replacing MySQL's strxmov with libc alternatives |
1899 |
sprintf(name+namelen*2+10, |
1900 |
"Enable %s plugin. Disable with --skip-%s (will save memory).", |
|
1901 |
plugin_name, name); |
|
1
by brian
clean slate |
1902 |
/*
|
1903 |
Now we have namelen * 2 + 10 (one char unused) + 7 + namelen + 9 +
|
|
1904 |
20 + namelen + 20 + 1 == namelen * 4 + 67.
|
|
1905 |
*/
|
|
1906 |
||
1907 |
options[0].comment= name + namelen*2 + 10; |
|
1908 |
}
|
|
1909 |
||
1119.6.1
by Stewart Smith
remove nasty malloc() optimisation in --help plugin for sql_plugin. Also document the general turdiness of this area of code. |
1910 |
/*
|
1911 |
This whole code around variables and command line parameters is turd
|
|
1912 |
soup.
|
|
1913 |
||
1914 |
e.g. the below assignemnt of having the plugin alaways enabled is never
|
|
1915 |
changed so that './drizzled --skip-innodb --help' shows innodb as enabled.
|
|
1916 |
||
1917 |
But this is just as broken as it was in MySQL and properly fixing everything
|
|
1918 |
is a decent amount of "future work"
|
|
1919 |
*/
|
|
1920 |
*enabled_value= true; /* by default, plugin enabled */ |
|
1921 |
||
1
by brian
clean slate |
1922 |
options[1].name= (options[0].name= name) + namelen + 1; |
1923 |
options[0].id= options[1].id= 256; /* must be >255. dup id ok */ |
|
1924 |
options[0].var_type= options[1].var_type= GET_BOOL; |
|
1925 |
options[0].arg_type= options[1].arg_type= NO_ARG; |
|
138
by Brian Aker
Refactoring around sql_plugin. |
1926 |
options[0].def_value= options[1].def_value= true; |
1
by brian
clean slate |
1927 |
options[0].value= options[0].u_max_value= |
1119.6.1
by Stewart Smith
remove nasty malloc() optimisation in --help plugin for sql_plugin. Also document the general turdiness of this area of code. |
1928 |
options[1].value= options[1].u_max_value= (char**) enabled_value; |
1
by brian
clean slate |
1929 |
options+= 2; |
1930 |
||
1931 |
/*
|
|
1932 |
Two passes as the 2nd pass will take pointer addresses for use
|
|
1933 |
by my_getopt and register_var() in the first pass uses realloc
|
|
1934 |
*/
|
|
1935 |
||
1093.3.4
by Monty Taylor
Naming cleanups. |
1936 |
for (plugin_option= tmp->getManifest().system_vars; |
1
by brian
clean slate |
1937 |
plugin_option && *plugin_option; plugin_option++, index++) |
1938 |
{
|
|
1939 |
opt= *plugin_option; |
|
520.1.21
by Brian Aker
THD -> Session rename |
1940 |
if (!(opt->flags & PLUGIN_VAR_SessionLOCAL)) |
1
by brian
clean slate |
1941 |
continue; |
1942 |
if (!(register_var(name, opt->name, opt->flags))) |
|
1943 |
continue; |
|
1944 |
switch (opt->flags & PLUGIN_VAR_TYPEMASK) { |
|
1945 |
case PLUGIN_VAR_BOOL: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1946 |
(((sessionvar_bool_t *)opt)->resolve)= mysql_sys_var_ptr_bool; |
1
by brian
clean slate |
1947 |
break; |
1948 |
case PLUGIN_VAR_INT: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1949 |
(((sessionvar_int_t *)opt)->resolve)= mysql_sys_var_ptr_int; |
1
by brian
clean slate |
1950 |
break; |
1951 |
case PLUGIN_VAR_LONG: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1952 |
(((sessionvar_long_t *)opt)->resolve)= mysql_sys_var_ptr_long; |
1
by brian
clean slate |
1953 |
break; |
1954 |
case PLUGIN_VAR_LONGLONG: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1955 |
(((sessionvar_int64_t_t *)opt)->resolve)= mysql_sys_var_ptr_int64_t; |
1
by brian
clean slate |
1956 |
break; |
1957 |
case PLUGIN_VAR_STR: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1958 |
(((sessionvar_str_t *)opt)->resolve)= mysql_sys_var_ptr_str; |
1
by brian
clean slate |
1959 |
break; |
1960 |
case PLUGIN_VAR_ENUM: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1961 |
(((sessionvar_enum_t *)opt)->resolve)= mysql_sys_var_ptr_enum; |
1
by brian
clean slate |
1962 |
break; |
1963 |
case PLUGIN_VAR_SET: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1964 |
(((sessionvar_set_t *)opt)->resolve)= mysql_sys_var_ptr_set; |
1
by brian
clean slate |
1965 |
break; |
1966 |
default: |
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
1967 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown variable type code 0x%x in plugin '%s'."), |
1
by brian
clean slate |
1968 |
opt->flags, plugin_name); |
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
1969 |
return(-1); |
1
by brian
clean slate |
1970 |
};
|
1971 |
}
|
|
1972 |
||
1093.3.4
by Monty Taylor
Naming cleanups. |
1973 |
for (plugin_option= tmp->getManifest().system_vars; |
1
by brian
clean slate |
1974 |
plugin_option && *plugin_option; plugin_option++, index++) |
1975 |
{
|
|
1976 |
switch ((opt= *plugin_option)->flags & PLUGIN_VAR_TYPEMASK) { |
|
1977 |
case PLUGIN_VAR_BOOL: |
|
1978 |
if (!opt->check) |
|
1979 |
opt->check= check_func_bool; |
|
1980 |
if (!opt->update) |
|
1981 |
opt->update= update_func_bool; |
|
1982 |
break; |
|
1983 |
case PLUGIN_VAR_INT: |
|
1984 |
if (!opt->check) |
|
1985 |
opt->check= check_func_int; |
|
1986 |
if (!opt->update) |
|
1987 |
opt->update= update_func_int; |
|
1988 |
break; |
|
1989 |
case PLUGIN_VAR_LONG: |
|
1990 |
if (!opt->check) |
|
1991 |
opt->check= check_func_long; |
|
1992 |
if (!opt->update) |
|
1993 |
opt->update= update_func_long; |
|
1994 |
break; |
|
1995 |
case PLUGIN_VAR_LONGLONG: |
|
1996 |
if (!opt->check) |
|
152
by Brian Aker
longlong replacement |
1997 |
opt->check= check_func_int64_t; |
1
by brian
clean slate |
1998 |
if (!opt->update) |
152
by Brian Aker
longlong replacement |
1999 |
opt->update= update_func_int64_t; |
1
by brian
clean slate |
2000 |
break; |
2001 |
case PLUGIN_VAR_STR: |
|
2002 |
if (!opt->check) |
|
2003 |
opt->check= check_func_str; |
|
2004 |
if (!opt->update) |
|
2005 |
{
|
|
2006 |
opt->update= update_func_str; |
|
9
by Brian Aker
Warnings cleanup |
2007 |
if ((opt->flags & (PLUGIN_VAR_MEMALLOC | PLUGIN_VAR_READONLY)) == false) |
1
by brian
clean slate |
2008 |
{
|
2009 |
opt->flags|= PLUGIN_VAR_READONLY; |
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
2010 |
errmsg_printf(ERRMSG_LVL_WARN, _("Server variable %s of plugin %s was forced " |
1
by brian
clean slate |
2011 |
"to be read-only: string variable without "
|
338
by Monty Taylor
Tagged more strings. |
2012 |
"update_func and PLUGIN_VAR_MEMALLOC flag"), |
1
by brian
clean slate |
2013 |
opt->name, plugin_name); |
2014 |
}
|
|
2015 |
}
|
|
2016 |
break; |
|
2017 |
case PLUGIN_VAR_ENUM: |
|
2018 |
if (!opt->check) |
|
2019 |
opt->check= check_func_enum; |
|
2020 |
if (!opt->update) |
|
2021 |
opt->update= update_func_long; |
|
2022 |
break; |
|
2023 |
case PLUGIN_VAR_SET: |
|
2024 |
if (!opt->check) |
|
2025 |
opt->check= check_func_set; |
|
2026 |
if (!opt->update) |
|
152
by Brian Aker
longlong replacement |
2027 |
opt->update= update_func_int64_t; |
1
by brian
clean slate |
2028 |
break; |
2029 |
default: |
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
2030 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown variable type code 0x%x in plugin '%s'."), |
1
by brian
clean slate |
2031 |
opt->flags, plugin_name); |
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
2032 |
return(-1); |
1
by brian
clean slate |
2033 |
}
|
2034 |
||
520.1.21
by Brian Aker
THD -> Session rename |
2035 |
if ((opt->flags & (PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_SessionLOCAL)) |
1
by brian
clean slate |
2036 |
== PLUGIN_VAR_NOCMDOPT) |
2037 |
continue; |
|
2038 |
||
2039 |
if (!opt->name) |
|
2040 |
{
|
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
2041 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Missing variable name in plugin '%s'."), |
1
by brian
clean slate |
2042 |
plugin_name); |
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
2043 |
return(-1); |
1
by brian
clean slate |
2044 |
}
|
2045 |
||
520.1.21
by Brian Aker
THD -> Session rename |
2046 |
if (!(opt->flags & PLUGIN_VAR_SessionLOCAL)) |
1
by brian
clean slate |
2047 |
{
|
2048 |
optnamelen= strlen(opt->name); |
|
2049 |
optname= (char*) alloc_root(mem_root, namelen + optnamelen + 2); |
|
673.2.1
by Toru Maesaka
First pass of replacing MySQL's strxmov with libc alternatives |
2050 |
sprintf(optname, "%s-%s", name, opt->name); |
1
by brian
clean slate |
2051 |
optnamelen= namelen + optnamelen + 1; |
2052 |
}
|
|
2053 |
else
|
|
2054 |
{
|
|
2055 |
/* this should not fail because register_var should create entry */
|
|
2056 |
if (!(v= find_bookmark(name, opt->name, opt->flags))) |
|
2057 |
{
|
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
2058 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Thread local variable '%s' not allocated " |
338
by Monty Taylor
Tagged more strings. |
2059 |
"in plugin '%s'."), opt->name, plugin_name); |
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
2060 |
return(-1); |
1
by brian
clean slate |
2061 |
}
|
2062 |
||
2063 |
*(int*)(opt + 1)= offset= v->offset; |
|
2064 |
||
2065 |
if (opt->flags & PLUGIN_VAR_NOCMDOPT) |
|
2066 |
continue; |
|
2067 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
2068 |
optname= (char*) memdup_root(mem_root, v->key + 1, |
1
by brian
clean slate |
2069 |
(optnamelen= v->name_len) + 1); |
2070 |
}
|
|
2071 |
||
2072 |
/* convert '_' to '-' */
|
|
2073 |
for (p= optname; *p; p++) |
|
2074 |
if (*p == '_') |
|
2075 |
*p= '-'; |
|
2076 |
||
2077 |
options->name= optname; |
|
2078 |
options->comment= opt->comment; |
|
2079 |
options->app_type= opt; |
|
2080 |
options->id= (options-1)->id + 1; |
|
2081 |
||
2082 |
plugin_opt_set_limits(options, opt); |
|
2083 |
||
520.1.21
by Brian Aker
THD -> Session rename |
2084 |
if (opt->flags & PLUGIN_VAR_SessionLOCAL) |
77.1.78
by Monty Taylor
One last bunch of warnings edits. |
2085 |
options->value= options->u_max_value= (char**) |
1
by brian
clean slate |
2086 |
(global_system_variables.dynamic_variables_ptr + offset); |
2087 |
else
|
|
77.1.78
by Monty Taylor
One last bunch of warnings edits. |
2088 |
options->value= options->u_max_value= *(char***) (opt + 1); |
1
by brian
clean slate |
2089 |
|
2090 |
options[1]= options[0]; |
|
2091 |
options[1].name= p= (char*) alloc_root(mem_root, optnamelen + 8); |
|
2092 |
options[1].comment= 0; // hidden |
|
673.2.1
by Toru Maesaka
First pass of replacing MySQL's strxmov with libc alternatives |
2093 |
sprintf(p,"plugin-%s",optname); |
1
by brian
clean slate |
2094 |
|
2095 |
options+= 2; |
|
2096 |
}
|
|
2097 |
||
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
2098 |
return(0); |
1
by brian
clean slate |
2099 |
}
|
2100 |
||
2101 |
||
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
2102 |
static my_option *construct_help_options(MEM_ROOT *mem_root, plugin::Handle *p) |
1
by brian
clean slate |
2103 |
{
|
2104 |
st_mysql_sys_var **opt; |
|
2105 |
my_option *opts; |
|
138
by Brian Aker
Refactoring around sql_plugin. |
2106 |
bool can_disable; |
482
by Brian Aker
Remove uint. |
2107 |
uint32_t count= EXTRA_OPTIONS; |
1
by brian
clean slate |
2108 |
|
1093.3.4
by Monty Taylor
Naming cleanups. |
2109 |
for (opt= p->getManifest().system_vars; opt && *opt; opt++, count+= 2) {}; |
1
by brian
clean slate |
2110 |
|
1093.3.5
by Monty Taylor
Removed a dynamic array. |
2111 |
opts= (my_option*)alloc_root(mem_root, (sizeof(my_option) * count)); |
2112 |
if (opts == NULL) |
|
1019.1.6
by Brian Aker
A number of random cleanups. |
2113 |
return NULL; |
1
by brian
clean slate |
2114 |
|
212.6.1
by Mats Kindahl
Replacing all bzero() calls with memset() calls and removing the bzero.c file. |
2115 |
memset(opts, 0, sizeof(my_option) * count); |
1
by brian
clean slate |
2116 |
|
1093.3.4
by Monty Taylor
Naming cleanups. |
2117 |
if ((my_strcasecmp(&my_charset_utf8_general_ci, p->getName().c_str(), "MyISAM") == 0)) |
138
by Brian Aker
Refactoring around sql_plugin. |
2118 |
can_disable= false; |
1093.3.4
by Monty Taylor
Naming cleanups. |
2119 |
else if ((my_strcasecmp(&my_charset_utf8_general_ci, p->getName().c_str(), "MEMORY") == 0)) |
138
by Brian Aker
Refactoring around sql_plugin. |
2120 |
can_disable= false; |
2121 |
else
|
|
2122 |
can_disable= true; |
|
2123 |
||
2124 |
||
2125 |
if (construct_options(mem_root, p, opts, can_disable)) |
|
1019.1.6
by Brian Aker
A number of random cleanups. |
2126 |
return NULL; |
1
by brian
clean slate |
2127 |
|
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
2128 |
return(opts); |
1
by brian
clean slate |
2129 |
}
|
2130 |
||
1101.1.27
by Monty Taylor
Fixed the plugin string valgrind leak. |
2131 |
void drizzle_add_plugin_sysvar(sys_var_pluginvar *var) |
2132 |
{
|
|
2133 |
plugin_sysvar_vec.push_back(var); |
|
2134 |
}
|
|
2135 |
||
2136 |
void drizzle_del_plugin_sysvar() |
|
2137 |
{
|
|
2138 |
vector<sys_var_pluginvar *>::iterator iter= plugin_sysvar_vec.begin(); |
|
2139 |
while(iter != plugin_sysvar_vec.end()) |
|
2140 |
{
|
|
2141 |
delete *iter; |
|
2142 |
++iter; |
|
2143 |
}
|
|
2144 |
plugin_sysvar_vec.clear(); |
|
2145 |
}
|
|
1
by brian
clean slate |
2146 |
|
2147 |
/*
|
|
2148 |
SYNOPSIS
|
|
2149 |
test_plugin_options()
|
|
2150 |
tmp_root temporary scratch space
|
|
2151 |
plugin internal plugin structure
|
|
2152 |
argc user supplied arguments
|
|
2153 |
argv user supplied arguments
|
|
2154 |
default_enabled default plugin enable status
|
|
2155 |
RETURNS:
|
|
2156 |
0 SUCCESS - plugin should be enabled/loaded
|
|
2157 |
NOTE:
|
|
2158 |
Requires that a write-lock is held on LOCK_system_variables_hash
|
|
2159 |
*/
|
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
2160 |
static int test_plugin_options(MEM_ROOT *tmp_root, plugin::Handle *tmp, |
135
by Brian Aker
Random cleanup. Dead partition tests, pass operator in sql_plugin, mtr based |
2161 |
int *argc, char **argv) |
1
by brian
clean slate |
2162 |
{
|
2163 |
struct sys_var_chain chain= { NULL, NULL }; |
|
138
by Brian Aker
Refactoring around sql_plugin. |
2164 |
bool can_disable; |
1
by brian
clean slate |
2165 |
st_mysql_sys_var **opt; |
2166 |
my_option *opts= NULL; |
|
2167 |
int error; |
|
2168 |
st_mysql_sys_var *o; |
|
2169 |
struct st_bookmark *var; |
|
482
by Brian Aker
Remove uint. |
2170 |
uint32_t len, count= EXTRA_OPTIONS; |
1
by brian
clean slate |
2171 |
|
1093.3.4
by Monty Taylor
Naming cleanups. |
2172 |
for (opt= tmp->getManifest().system_vars; opt && *opt; opt++) |
1
by brian
clean slate |
2173 |
count+= 2; /* --{plugin}-{optname} and --plugin-{plugin}-{optname} */ |
2174 |
||
1093.3.4
by Monty Taylor
Naming cleanups. |
2175 |
if ((my_strcasecmp(&my_charset_utf8_general_ci, tmp->getName().c_str(), "MyISAM") == 0)) |
138
by Brian Aker
Refactoring around sql_plugin. |
2176 |
can_disable= false; |
1093.3.4
by Monty Taylor
Naming cleanups. |
2177 |
else if ((my_strcasecmp(&my_charset_utf8_general_ci, tmp->getName().c_str(), "MEMORY") == 0)) |
138
by Brian Aker
Refactoring around sql_plugin. |
2178 |
can_disable= false; |
2179 |
else
|
|
2180 |
can_disable= true; |
|
1
by brian
clean slate |
2181 |
|
2182 |
if (count > EXTRA_OPTIONS || (*argc > 1)) |
|
2183 |
{
|
|
2184 |
if (!(opts= (my_option*) alloc_root(tmp_root, sizeof(my_option) * count))) |
|
2185 |
{
|
|
1093.3.4
by Monty Taylor
Naming cleanups. |
2186 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Out of memory for plugin '%s'."), tmp->getName().c_str()); |
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
2187 |
return(-1); |
1
by brian
clean slate |
2188 |
}
|
212.6.1
by Mats Kindahl
Replacing all bzero() calls with memset() calls and removing the bzero.c file. |
2189 |
memset(opts, 0, sizeof(my_option) * count); |
1
by brian
clean slate |
2190 |
|
138
by Brian Aker
Refactoring around sql_plugin. |
2191 |
if (construct_options(tmp_root, tmp, opts, can_disable)) |
1
by brian
clean slate |
2192 |
{
|
1093.3.4
by Monty Taylor
Naming cleanups. |
2193 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Bad options for plugin '%s'."), tmp->getName().c_str()); |
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
2194 |
return(-1); |
1
by brian
clean slate |
2195 |
}
|
2196 |
||
2197 |
error= handle_options(argc, &argv, opts, get_one_plugin_option); |
|
2198 |
(*argc)++; /* add back one for the program name */ |
|
2199 |
||
2200 |
if (error) |
|
2201 |
{
|
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
2202 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Parsing options for plugin '%s' failed."), |
1093.3.4
by Monty Taylor
Naming cleanups. |
2203 |
tmp->getName().c_str()); |
1
by brian
clean slate |
2204 |
goto err; |
2205 |
}
|
|
2206 |
}
|
|
2207 |
||
2208 |
error= 1; |
|
2209 |
||
779.3.53
by Monty Taylor
Revert the fail. |
2210 |
{
|
1093.3.4
by Monty Taylor
Naming cleanups. |
2211 |
for (opt= tmp->getManifest().system_vars; opt && *opt; opt++) |
779.3.53
by Monty Taylor
Revert the fail. |
2212 |
{
|
1106.1.2
by Brian Aker
Additional fixes from Monty |
2213 |
sys_var *v; |
779.3.53
by Monty Taylor
Revert the fail. |
2214 |
if (((o= *opt)->flags & PLUGIN_VAR_NOSYSVAR)) |
2215 |
continue; |
|
2216 |
||
1093.3.4
by Monty Taylor
Naming cleanups. |
2217 |
if ((var= find_bookmark(tmp->getName().c_str(), o->name, o->flags))) |
1101.1.27
by Monty Taylor
Fixed the plugin string valgrind leak. |
2218 |
v= new sys_var_pluginvar(var->key + 1, o); |
779.3.53
by Monty Taylor
Revert the fail. |
2219 |
else
|
2220 |
{
|
|
1093.3.4
by Monty Taylor
Naming cleanups. |
2221 |
len= tmp->getName().length() + strlen(o->name) + 2; |
1101.1.27
by Monty Taylor
Fixed the plugin string valgrind leak. |
2222 |
string vname(tmp->getName()); |
2223 |
vname.push_back('-'); |
|
2224 |
vname.append(o->name); |
|
2225 |
transform(vname.begin(), vname.end(), vname.begin(), ::tolower); |
|
2226 |
string::iterator p= vname.begin(); |
|
2227 |
while (p != vname.end()) |
|
2228 |
{
|
|
779.3.53
by Monty Taylor
Revert the fail. |
2229 |
if (*p == '-') |
2230 |
*p= '_'; |
|
1101.1.27
by Monty Taylor
Fixed the plugin string valgrind leak. |
2231 |
++p; |
2232 |
}
|
|
779.3.53
by Monty Taylor
Revert the fail. |
2233 |
|
1101.1.27
by Monty Taylor
Fixed the plugin string valgrind leak. |
2234 |
v= new sys_var_pluginvar(vname, o); |
779.3.53
by Monty Taylor
Revert the fail. |
2235 |
}
|
2236 |
assert(v); /* check that an object was actually constructed */ |
|
2237 |
||
1101.1.27
by Monty Taylor
Fixed the plugin string valgrind leak. |
2238 |
drizzle_add_plugin_sysvar(static_cast<sys_var_pluginvar *>(v)); |
779.3.53
by Monty Taylor
Revert the fail. |
2239 |
/*
|
2240 |
Add to the chain of variables.
|
|
2241 |
Done like this for easier debugging so that the
|
|
2242 |
pointer to v is not lost on optimized builds.
|
|
2243 |
*/
|
|
2244 |
v->chain_sys_var(&chain); |
|
2245 |
}
|
|
2246 |
if (chain.first) |
|
2247 |
{
|
|
1055.2.20
by Jay Pipes
Refactors sys_var class -- doxygenates and documents the class members and functions. Protects all member variables and adds public getters/setters. |
2248 |
chain.last->setNext(NULL); |
779.3.53
by Monty Taylor
Revert the fail. |
2249 |
if (mysql_add_sys_var_chain(chain.first, NULL)) |
2250 |
{
|
|
2251 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Plugin '%s' has conflicting system variables"), |
|
1093.3.4
by Monty Taylor
Naming cleanups. |
2252 |
tmp->getName().c_str()); |
779.3.53
by Monty Taylor
Revert the fail. |
2253 |
goto err; |
2254 |
}
|
|
2255 |
tmp->system_vars= chain.first; |
|
2256 |
}
|
|
2257 |
return(0); |
|
2258 |
}
|
|
2259 |
||
1
by brian
clean slate |
2260 |
err: |
2261 |
if (opts) |
|
2262 |
my_cleanup_options(opts); |
|
51.1.1
by Jay Pipes
Merged PatG's removal of various DBUG stuff with still keeping DBUG_ASSERT calls since they seem to be breaking test runs |
2263 |
return(error); |
1
by brian
clean slate |
2264 |
}
|
2265 |
||
2266 |
||
2267 |
/****************************************************************************
|
|
2268 |
Help Verbose text with Plugin System Variables
|
|
2269 |
****************************************************************************/
|
|
2270 |
||
1093.3.5
by Monty Taylor
Removed a dynamic array. |
2271 |
class OptionCmp |
2272 |
{
|
|
2273 |
public: |
|
2274 |
bool operator() (const my_option &a, const my_option &b) |
|
2275 |
{
|
|
2276 |
return my_strcasecmp(&my_charset_utf8_general_ci, a.name, b.name); |
|
2277 |
}
|
|
2278 |
};
|
|
2279 |
||
2280 |
||
2281 |
void my_print_help_inc_plugins(my_option *main_options) |
|
2282 |
{
|
|
2283 |
vector<my_option> all_options; |
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
2284 |
plugin::Handle *p; |
1
by brian
clean slate |
2285 |
MEM_ROOT mem_root; |
1093.3.5
by Monty Taylor
Removed a dynamic array. |
2286 |
my_option *opt= NULL; |
1
by brian
clean slate |
2287 |
|
2288 |
init_alloc_root(&mem_root, 4096, 4096); |
|
2289 |
||
2290 |
if (initialized) |
|
482
by Brian Aker
Remove uint. |
2291 |
for (uint32_t idx= 0; idx < plugin_array.elements; idx++) |
1
by brian
clean slate |
2292 |
{
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
2293 |
p= *dynamic_element(&plugin_array, idx, plugin::Handle **); |
1
by brian
clean slate |
2294 |
|
1093.3.5
by Monty Taylor
Removed a dynamic array. |
2295 |
if (p->getManifest().system_vars == NULL) |
2296 |
continue; |
|
2297 |
||
2298 |
opt= construct_help_options(&mem_root, p); |
|
2299 |
if (opt == NULL) |
|
1
by brian
clean slate |
2300 |
continue; |
2301 |
||
2302 |
/* Only options with a non-NULL comment are displayed in help text */
|
|
2303 |
for (;opt->id; opt++) |
|
1093.3.5
by Monty Taylor
Removed a dynamic array. |
2304 |
{
|
1
by brian
clean slate |
2305 |
if (opt->comment) |
1093.3.5
by Monty Taylor
Removed a dynamic array. |
2306 |
{
|
2307 |
all_options.push_back(*opt); |
|
2308 |
||
2309 |
}
|
|
2310 |
}
|
|
1
by brian
clean slate |
2311 |
}
|
2312 |
||
2313 |
for (;main_options->id; main_options++) |
|
1093.3.5
by Monty Taylor
Removed a dynamic array. |
2314 |
{
|
2315 |
if (main_options->comment) |
|
2316 |
{
|
|
2317 |
all_options.push_back(*main_options); |
|
2318 |
}
|
|
2319 |
}
|
|
1
by brian
clean slate |
2320 |
|
1093.3.5
by Monty Taylor
Removed a dynamic array. |
2321 |
/**
|
2322 |
* @TODO: Fix the my_option building so that it doens't break sort
|
|
2323 |
*
|
|
2324 |
* sort(all_options.begin(), all_options.end(), OptionCmp());
|
|
2325 |
*/
|
|
1
by brian
clean slate |
2326 |
|
2327 |
/* main_options now points to the empty option terminator */
|
|
1093.3.5
by Monty Taylor
Removed a dynamic array. |
2328 |
all_options.push_back(*main_options); |
2329 |
||
2330 |
my_print_help(&*(all_options.begin())); |
|
2331 |
my_print_variables(&*(all_options.begin())); |
|
2332 |
||
1
by brian
clean slate |
2333 |
free_root(&mem_root, MYF(0)); |
1093.3.5
by Monty Taylor
Removed a dynamic array. |
2334 |
|
1
by brian
clean slate |
2335 |
}
|
2336 |