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 |
||
1241.9.36
by Monty Taylor
ZOMG. I deleted drizzled/server_includes.h. |
16 |
#include "config.h" |
499.2.9
by Mark Atwood
fix mistakes |
17 |
|
1122.2.13
by Monty Taylor
Header cleanup. |
18 |
#include <dlfcn.h> |
499.2.9
by Mark Atwood
fix mistakes |
19 |
|
1502.3.1
by iwamatsu at nigauri
Add cstdio include to files needing it. Fixes the build on some debian |
20 |
#include <cstdio> |
534
by Monty Taylor
Removed stxnmov. Also deleted strstr which had already been removed. |
21 |
#include <string> |
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
22 |
#include <vector> |
873.2.21
by Monty Taylor
Removed the HASH for plugin_hash. |
23 |
#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). |
24 |
#include <algorithm> |
534
by Monty Taylor
Removed stxnmov. Also deleted strstr which had already been removed. |
25 |
|
1410.3.4
by Djellel E. Difallah
update references to old my_'s |
26 |
#include "drizzled/option.h" |
1241.9.57
by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined. |
27 |
#include "drizzled/my_hash.h" |
1241.9.64
by Monty Taylor
Moved remaining non-public portions of mysys and mystrings to drizzled/internal. |
28 |
#include "drizzled/internal/m_string.h" |
1122.2.13
by Monty Taylor
Header cleanup. |
29 |
|
1251.2.2
by Jay Pipes
Pulls MyISAM-specific server variables into the MyISAM |
30 |
#include "drizzled/plugin.h" |
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
31 |
#include "drizzled/module/load_list.h" |
32 |
#include "drizzled/module/library.h" |
|
33 |
#include "drizzled/module/registry.h" |
|
1122.2.13
by Monty Taylor
Header cleanup. |
34 |
#include "drizzled/sql_parse.h" |
35 |
#include "drizzled/show.h" |
|
1185
by Brian Aker
Merge Engine changes. |
36 |
#include "drizzled/cursor.h" |
1122.2.13
by Monty Taylor
Header cleanup. |
37 |
#include "drizzled/set_var.h" |
38 |
#include "drizzled/session.h" |
|
39 |
#include "drizzled/item/null.h" |
|
40 |
#include "drizzled/error.h" |
|
41 |
#include "drizzled/gettext.h" |
|
1130.3.23
by Monty Taylor
Removed more server_includes.h from headers. |
42 |
#include "drizzled/errmsg_print.h" |
1241.9.12
by Monty Taylor
Trims more out of server_includes.h. |
43 |
#include "drizzled/strfunc.h" |
1241.9.31
by Monty Taylor
Moved global pthread variables into their own header. |
44 |
#include "drizzled/pthread_globals.h" |
1283.1.5
by Monty Taylor
Added --plugin-remove option, which prunes plugins from the list of plugins |
45 |
#include "drizzled/util/tokenize.h" |
1122.2.13
by Monty Taylor
Header cleanup. |
46 |
|
47 |
/* FreeBSD 2.2.2 does not define RTLD_NOW) */
|
|
48 |
#ifndef RTLD_NOW
|
|
49 |
#define RTLD_NOW 1
|
|
50 |
#endif
|
|
1
by brian
clean slate |
51 |
|
534
by Monty Taylor
Removed stxnmov. Also deleted strstr which had already been removed. |
52 |
using namespace std; |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
53 |
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
54 |
/** These exist just to prevent symbols from being optimized out */
|
55 |
typedef drizzled::module::Manifest drizzled_builtin_list[]; |
|
56 |
extern drizzled_builtin_list PANDORA_BUILTIN_SYMBOLS_LIST; |
|
57 |
drizzled::module::Manifest *drizzled_builtins[]= |
|
58 |
{
|
|
59 |
PANDORA_BUILTIN_SYMBOLS_LIST, NULL |
|
60 |
};
|
|
61 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
62 |
namespace drizzled |
63 |
{
|
|
992.1.39
by Monty Taylor
Removed the m4-based plugin system. |
64 |
|
1122.2.13
by Monty Taylor
Header cleanup. |
65 |
|
1101.1.27
by Monty Taylor
Fixed the plugin string valgrind leak. |
66 |
class sys_var_pluginvar; |
67 |
static vector<sys_var_pluginvar *> plugin_sysvar_vec; |
|
1
by brian
clean slate |
68 |
|
1192.3.7
by Monty Taylor
Added code necessary for building plugins dynamically. |
69 |
char *opt_plugin_add= NULL; |
1283.1.5
by Monty Taylor
Added --plugin-remove option, which prunes plugins from the list of plugins |
70 |
char *opt_plugin_remove= NULL; |
1
by brian
clean slate |
71 |
char *opt_plugin_load= NULL; |
72 |
char *opt_plugin_dir_ptr; |
|
73 |
char opt_plugin_dir[FN_REFLEN]; |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
74 |
const char *opt_plugin_load_default= PANDORA_PLUGIN_LIST; |
1530.2.3
by Monty Taylor
Changed the builtin plugin code path to work exactly the same as dynamic. |
75 |
const char *builtin_plugins= PANDORA_BUILTIN_LIST; |
1
by brian
clean slate |
76 |
|
77 |
/* Note that 'int version' must be the first field of every plugin
|
|
78 |
sub-structure (plugin->info).
|
|
79 |
*/
|
|
80 |
||
962.1.6
by Brian Aker
Cut down on shutdown loop of plugins (cutting stuff out in order to simplify |
81 |
static bool initialized= false; |
1
by brian
clean slate |
82 |
|
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
83 |
|
1
by brian
clean slate |
84 |
static bool reap_needed= false; |
85 |
||
86 |
/*
|
|
87 |
write-lock on LOCK_system_variables_hash is required before modifying
|
|
88 |
the following variables/structures
|
|
89 |
*/
|
|
1485
by Brian Aker
Updates to confine memroot |
90 |
static memory::Root plugin_mem_root(4096); |
482
by Brian Aker
Remove uint. |
91 |
static uint32_t global_variables_dynamic_size= 0; |
1
by brian
clean slate |
92 |
static HASH bookmark_hash; |
93 |
||
94 |
||
95 |
/*
|
|
96 |
hidden part of opaque value passed to variable check functions.
|
|
97 |
Used to provide a object-like structure to non C++ consumers.
|
|
98 |
*/
|
|
1228.1.5
by Monty Taylor
Merged in some naming things. |
99 |
struct st_item_value_holder : public drizzle_value |
1
by brian
clean slate |
100 |
{
|
101 |
Item *item; |
|
102 |
};
|
|
103 |
||
104 |
||
105 |
/*
|
|
106 |
stored in bookmark_hash, this structure is never removed from the
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
107 |
hash and is used to mark a single offset for a session local variable
|
1
by brian
clean slate |
108 |
even if plugins have been uninstalled and reinstalled, repeatedly.
|
109 |
This structure is allocated from plugin_mem_root.
|
|
110 |
||
111 |
The key format is as follows:
|
|
112 |
1 byte - variable type code
|
|
113 |
name_len bytes - variable name
|
|
114 |
'\0' - end of key
|
|
115 |
*/
|
|
116 |
struct st_bookmark |
|
117 |
{
|
|
482
by Brian Aker
Remove uint. |
118 |
uint32_t name_len; |
1
by brian
clean slate |
119 |
int offset; |
482
by Brian Aker
Remove uint. |
120 |
uint32_t version; |
1
by brian
clean slate |
121 |
char key[1]; |
122 |
};
|
|
123 |
||
124 |
||
125 |
/*
|
|
126 |
sys_var class for access to all plugin variables visible to the user
|
|
127 |
*/
|
|
128 |
class sys_var_pluginvar: public sys_var |
|
129 |
{
|
|
130 |
public: |
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
131 |
module::Module *plugin; |
1228.1.5
by Monty Taylor
Merged in some naming things. |
132 |
drizzle_sys_var *plugin_var; |
1
by brian
clean slate |
133 |
|
1101.1.27
by Monty Taylor
Fixed the plugin string valgrind leak. |
134 |
sys_var_pluginvar(const std::string name_arg, |
1228.1.5
by Monty Taylor
Merged in some naming things. |
135 |
drizzle_sys_var *plugin_var_arg) |
1
by brian
clean slate |
136 |
:sys_var(name_arg), plugin_var(plugin_var_arg) {} |
137 |
sys_var_pluginvar *cast_pluginvar() { return this; } |
|
138 |
bool is_readonly() const { return plugin_var->flags & PLUGIN_VAR_READONLY; } |
|
1273.13.24
by Brian Aker
Updating style, simplified code. |
139 |
bool check_type(sql_var_t type) |
520.1.21
by Brian Aker
THD -> Session rename |
140 |
{ return !(plugin_var->flags & PLUGIN_VAR_SessionLOCAL) && type != OPT_GLOBAL; } |
1
by brian
clean slate |
141 |
bool check_update_type(Item_result type); |
142 |
SHOW_TYPE show_type(); |
|
1273.13.24
by Brian Aker
Updating style, simplified code. |
143 |
unsigned char* real_value_ptr(Session *session, sql_var_t type); |
1
by brian
clean slate |
144 |
TYPELIB* plugin_var_typelib(void); |
1273.13.24
by Brian Aker
Updating style, simplified code. |
145 |
unsigned char* value_ptr(Session *session, sql_var_t type, |
779.3.10
by Monty Taylor
Turned on -Wshadow. |
146 |
const LEX_STRING *base); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
147 |
bool check(Session *session, set_var *var); |
1273.13.24
by Brian Aker
Updating style, simplified code. |
148 |
bool check_default(sql_var_t) |
77.1.46
by Monty Taylor
Finished the warnings work! |
149 |
{ return is_readonly(); } |
1273.13.24
by Brian Aker
Updating style, simplified code. |
150 |
void set_default(Session *session, sql_var_t); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
151 |
bool update(Session *session, set_var *var); |
1
by brian
clean slate |
152 |
};
|
153 |
||
154 |
||
155 |
/* prototypes */
|
|
1283.1.5
by Monty Taylor
Added --plugin-remove option, which prunes plugins from the list of plugins |
156 |
static void plugin_prune_list(vector<string> &plugin_list, |
157 |
const vector<string> &plugins_to_remove); |
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
158 |
static bool plugin_load_list(module::Registry ®istry, |
1253.1.3
by Monty Taylor
MEM_ROOT == memory::Root |
159 |
memory::Root *tmp_root, int *argc, char **argv, |
1530.2.3
by Monty Taylor
Changed the builtin plugin code path to work exactly the same as dynamic. |
160 |
const set<string> &plugin_list, |
161 |
bool builtin= false); |
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
162 |
static int test_plugin_options(memory::Root *, module::Module *, |
135
by Brian Aker
Random cleanup. Dead partition tests, pass operator in sql_plugin, mtr based |
163 |
int *, char **); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
164 |
static void unlock_variables(Session *session, struct system_variables *vars); |
165 |
static void cleanup_variables(Session *session, struct system_variables *vars); |
|
1
by brian
clean slate |
166 |
static void plugin_vars_free_values(sys_var *vars); |
167 |
||
168 |
/* declared in set_var.cc */
|
|
482
by Brian Aker
Remove uint. |
169 |
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 |
170 |
extern bool throw_bounds_warning(Session *session, bool fixed, bool unsignd, |
1022.2.38
by Monty Taylor
Changed name to std::string. |
171 |
const std::string &name, int64_t val); |
172 |
||
173 |
static bool throw_bounds_warning(Session *session, bool fixed, bool unsignd, |
|
174 |
const char *name, int64_t val) |
|
175 |
{
|
|
176 |
const std::string name_str(name); |
|
177 |
return throw_bounds_warning(session, fixed, unsignd, name_str, val); |
|
178 |
}
|
|
1
by brian
clean slate |
179 |
|
180 |
/****************************************************************************
|
|
181 |
Value type thunks, allows the C world to play in the C++ world
|
|
182 |
****************************************************************************/
|
|
183 |
||
1228.1.5
by Monty Taylor
Merged in some naming things. |
184 |
static int item_value_type(drizzle_value *value) |
1
by brian
clean slate |
185 |
{
|
186 |
switch (((st_item_value_holder*)value)->item->result_type()) { |
|
187 |
case INT_RESULT: |
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
188 |
return DRIZZLE_VALUE_TYPE_INT; |
1
by brian
clean slate |
189 |
case REAL_RESULT: |
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
190 |
return DRIZZLE_VALUE_TYPE_REAL; |
1
by brian
clean slate |
191 |
default: |
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
192 |
return DRIZZLE_VALUE_TYPE_STRING; |
1
by brian
clean slate |
193 |
}
|
194 |
}
|
|
195 |
||
1228.1.5
by Monty Taylor
Merged in some naming things. |
196 |
static const char *item_val_str(drizzle_value *value, |
1
by brian
clean slate |
197 |
char *buffer, int *length) |
198 |
{
|
|
199 |
String str(buffer, *length, system_charset_info), *res; |
|
200 |
if (!(res= ((st_item_value_holder*)value)->item->val_str(&str))) |
|
201 |
return NULL; |
|
202 |
*length= res->length(); |
|
203 |
if (res->c_ptr_quick() == buffer) |
|
204 |
return buffer; |
|
205 |
||
206 |
/*
|
|
207 |
Lets be nice and create a temporary string since the
|
|
208 |
buffer was too small
|
|
209 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
210 |
return current_session->strmake(res->c_ptr_quick(), res->length()); |
1
by brian
clean slate |
211 |
}
|
212 |
||
213 |
||
1228.1.5
by Monty Taylor
Merged in some naming things. |
214 |
static int item_val_int(drizzle_value *value, int64_t *buf) |
1
by brian
clean slate |
215 |
{
|
216 |
Item *item= ((st_item_value_holder*)value)->item; |
|
217 |
*buf= item->val_int(); |
|
218 |
if (item->is_null()) |
|
219 |
return 1; |
|
220 |
return 0; |
|
221 |
}
|
|
222 |
||
223 |
||
1228.1.5
by Monty Taylor
Merged in some naming things. |
224 |
static int item_val_real(drizzle_value *value, double *buf) |
1
by brian
clean slate |
225 |
{
|
226 |
Item *item= ((st_item_value_holder*)value)->item; |
|
227 |
*buf= item->val_real(); |
|
228 |
if (item->is_null()) |
|
229 |
return 1; |
|
230 |
return 0; |
|
231 |
}
|
|
232 |
||
233 |
||
234 |
/****************************************************************************
|
|
235 |
Plugin support code
|
|
236 |
****************************************************************************/
|
|
237 |
||
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
238 |
|
1
by brian
clean slate |
239 |
|
240 |
||
241 |
/*
|
|
242 |
NOTE
|
|
243 |
Requires that a write-lock is held on LOCK_system_variables_hash
|
|
244 |
*/
|
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
245 |
static bool plugin_add(module::Registry ®istry, memory::Root *tmp_root, |
246 |
module::Library *library, |
|
1192.5.2
by Monty Taylor
Removed the ununsed REPORT_TO_USER flag. Changed a few returns to return NULL |
247 |
int *argc, char **argv) |
1
by brian
clean slate |
248 |
{
|
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
249 |
if (! initialized) |
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
250 |
return true; |
908.2.1
by Monty Taylor
First pass at refactoring plugins - factored out sql_map. |
251 |
|
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
252 |
if (registry.find(library->getName())) |
1
by brian
clean slate |
253 |
{
|
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
254 |
errmsg_printf(ERRMSG_LVL_WARN, ER(ER_PLUGIN_EXISTS), |
255 |
library->getName().c_str()); |
|
256 |
return false; |
|
1
by brian
clean slate |
257 |
}
|
1093.3.4
by Monty Taylor
Naming cleanups. |
258 |
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
259 |
module::Module *tmp= NULL; |
1
by brian
clean slate |
260 |
/* Find plugin by name */
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
261 |
const module::Manifest *manifest= library->getManifest(); |
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
262 |
|
1284.2.1
by Monty Taylor
Add a fatal error if a plugin has a name which has already been registered. |
263 |
if (registry.find(manifest->name)) |
264 |
{
|
|
265 |
errmsg_printf(ERRMSG_LVL_ERROR, |
|
266 |
_("Plugin '%s' contains the name '%s' in its manifest, which " |
|
267 |
"has already been registered.\n"), |
|
268 |
library->getName().c_str(), |
|
269 |
manifest->name); |
|
270 |
return true; |
|
271 |
}
|
|
272 |
||
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
273 |
tmp= new (std::nothrow) module::Module(manifest, library); |
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
274 |
if (tmp == NULL) |
275 |
return true; |
|
276 |
||
277 |
if (!test_plugin_options(tmp_root, tmp, argc, argv)) |
|
1
by brian
clean slate |
278 |
{
|
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
279 |
registry.add(tmp); |
280 |
return false; |
|
1
by brian
clean slate |
281 |
}
|
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
282 |
errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_CANT_FIND_DL_ENTRY), |
283 |
library->getName().c_str()); |
|
284 |
return true; |
|
1
by brian
clean slate |
285 |
}
|
286 |
||
287 |
||
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
288 |
static void delete_module(module::Module *module) |
1
by brian
clean slate |
289 |
{
|
290 |
/* Free allocated strings before deleting the plugin. */
|
|
1192.2.3
by Monty Taylor
Renamed plugin::Handle to plugin::Module for clarity. |
291 |
plugin_vars_free_values(module->system_vars); |
292 |
module->isInited= false; |
|
658
by Brian Aker
Part removal of my_pthread.h |
293 |
pthread_rwlock_wrlock(&LOCK_system_variables_hash); |
1192.2.3
by Monty Taylor
Renamed plugin::Handle to plugin::Module for clarity. |
294 |
mysql_del_sys_var_chain(module->system_vars); |
658
by Brian Aker
Part removal of my_pthread.h |
295 |
pthread_rwlock_unlock(&LOCK_system_variables_hash); |
1192.2.3
by Monty Taylor
Renamed plugin::Handle to plugin::Module for clarity. |
296 |
delete module; |
1
by brian
clean slate |
297 |
}
|
298 |
||
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
299 |
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
300 |
static void reap_plugins(module::Registry ®istry) |
1
by brian
clean slate |
301 |
{
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
302 |
std::map<std::string, module::Module *>::const_iterator modules= |
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
303 |
registry.getModulesMap().begin(); |
1324.2.3
by Monty Taylor
Remove plugin deinit. |
304 |
|
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
305 |
while (modules != registry.getModulesMap().end()) |
1
by brian
clean slate |
306 |
{
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
307 |
module::Module *module= (*modules).second; |
1324.2.3
by Monty Taylor
Remove plugin deinit. |
308 |
delete_module(module); |
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
309 |
++modules; |
688
by Brian Aker
Second pass through memory allocation issues (this solves the ones around |
310 |
}
|
1324.2.3
by Monty Taylor
Remove plugin deinit. |
311 |
|
1101.1.27
by Monty Taylor
Fixed the plugin string valgrind leak. |
312 |
drizzle_del_plugin_sysvar(); |
1
by brian
clean slate |
313 |
}
|
314 |
||
1119.1.1
by Monty Taylor
--help doesn't need --datadir to work. |
315 |
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
316 |
static void plugin_initialize_vars(module::Module *module) |
1
by brian
clean slate |
317 |
{
|
318 |
/*
|
|
319 |
set the plugin attribute of plugin's sys vars so they are pointing
|
|
320 |
to the active plugin
|
|
321 |
*/
|
|
1192.2.3
by Monty Taylor
Renamed plugin::Handle to plugin::Module for clarity. |
322 |
if (module->system_vars) |
1
by brian
clean slate |
323 |
{
|
1192.2.3
by Monty Taylor
Renamed plugin::Handle to plugin::Module for clarity. |
324 |
sys_var_pluginvar *var= module->system_vars->cast_pluginvar(); |
1
by brian
clean slate |
325 |
for (;;) |
326 |
{
|
|
1192.2.3
by Monty Taylor
Renamed plugin::Handle to plugin::Module for clarity. |
327 |
var->plugin= module; |
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. |
328 |
if (! var->getNext()) |
1
by brian
clean slate |
329 |
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. |
330 |
var= var->getNext()->cast_pluginvar(); |
1
by brian
clean slate |
331 |
}
|
332 |
}
|
|
1119.1.1
by Monty Taylor
--help doesn't need --datadir to work. |
333 |
}
|
334 |
||
335 |
||
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
336 |
static bool plugin_initialize(module::Registry ®istry, |
337 |
module::Module *module) |
|
1119.1.1
by Monty Taylor
--help doesn't need --datadir to work. |
338 |
{
|
1192.2.3
by Monty Taylor
Renamed plugin::Handle to plugin::Module for clarity. |
339 |
assert(module->isInited == false); |
1119.1.1
by Monty Taylor
--help doesn't need --datadir to work. |
340 |
|
1530.2.6
by Monty Taylor
Moved plugin::Context to module::Context. |
341 |
module::Context loading_context(registry, module); |
1192.2.3
by Monty Taylor
Renamed plugin::Handle to plugin::Module for clarity. |
342 |
if (module->getManifest().init) |
1119.1.1
by Monty Taylor
--help doesn't need --datadir to work. |
343 |
{
|
1324.2.1
by Monty Taylor
Create a plugin::Context object to carry information about the plugin module |
344 |
if (module->getManifest().init(loading_context)) |
1119.1.1
by Monty Taylor
--help doesn't need --datadir to work. |
345 |
{
|
346 |
errmsg_printf(ERRMSG_LVL_ERROR, |
|
347 |
_("Plugin '%s' init function returned error.\n"), |
|
1192.2.3
by Monty Taylor
Renamed plugin::Handle to plugin::Module for clarity. |
348 |
module->getName().c_str()); |
1119.1.1
by Monty Taylor
--help doesn't need --datadir to work. |
349 |
return true; |
350 |
}
|
|
351 |
}
|
|
1192.2.3
by Monty Taylor
Renamed plugin::Handle to plugin::Module for clarity. |
352 |
module->isInited= true; |
1119.1.1
by Monty Taylor
--help doesn't need --datadir to work. |
353 |
|
1
by brian
clean slate |
354 |
|
965.1.1
by Brian Aker
Refactor plugin loading to remove mask (one step closer to getting rid of |
355 |
return false; |
1
by brian
clean slate |
356 |
}
|
357 |
||
358 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
359 |
static unsigned char *get_bookmark_hash_key(const unsigned char *buff, |
360 |
size_t *length, bool) |
|
1
by brian
clean slate |
361 |
{
|
362 |
struct st_bookmark *var= (st_bookmark *)buff; |
|
363 |
*length= var->name_len + 1; |
|
481
by Brian Aker
Remove all of uchar. |
364 |
return (unsigned char*) var->key; |
1
by brian
clean slate |
365 |
}
|
366 |
||
367 |
||
368 |
/*
|
|
369 |
The logic is that we first load and initialize all compiled in plugins.
|
|
370 |
From there we load up the dynamic types (assuming we have not been told to
|
|
371 |
skip this part).
|
|
372 |
||
373 |
Finally we initialize everything, aka the dynamic that have yet to initialize.
|
|
374 |
*/
|
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
375 |
bool plugin_init(module::Registry ®istry, |
1241.10.4
by Monty Taylor
Actually throw errors on failure to init plugins. |
376 |
int *argc, char **argv, |
377 |
bool skip_init) |
|
1
by brian
clean slate |
378 |
{
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
379 |
module::Module *module; |
1485
by Brian Aker
Updates to confine memroot |
380 |
memory::Root tmp_root(4096); |
1
by brian
clean slate |
381 |
|
382 |
if (initialized) |
|
1241.10.4
by Monty Taylor
Actually throw errors on failure to init plugins. |
383 |
return false; |
1
by brian
clean slate |
384 |
|
385 |
if (hash_init(&bookmark_hash, &my_charset_bin, 16, 0, 0, |
|
386 |
get_bookmark_hash_key, NULL, HASH_UNIQUE)) |
|
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
387 |
{
|
1487
by Brian Aker
More updates for memory::Root |
388 |
tmp_root.free_root(MYF(0)); |
1241.10.4
by Monty Taylor
Actually throw errors on failure to init plugins. |
389 |
return true; |
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
390 |
}
|
391 |
||
1
by brian
clean slate |
392 |
|
393 |
initialized= 1; |
|
394 |
||
1530.2.3
by Monty Taylor
Changed the builtin plugin code path to work exactly the same as dynamic. |
395 |
vector<string> builtin_list; |
396 |
tokenize(builtin_plugins, builtin_list, ",", true); |
|
1
by brian
clean slate |
397 |
|
1241.10.4
by Monty Taylor
Actually throw errors on failure to init plugins. |
398 |
bool load_failed= false; |
1283.1.5
by Monty Taylor
Added --plugin-remove option, which prunes plugins from the list of plugins |
399 |
vector<string> plugin_list; |
400 |
if (opt_plugin_load) |
|
401 |
{
|
|
402 |
tokenize(opt_plugin_load, plugin_list, ",", true); |
|
403 |
}
|
|
404 |
else
|
|
405 |
{
|
|
406 |
tokenize(opt_plugin_load_default, plugin_list, ",", true); |
|
407 |
}
|
|
408 |
if (opt_plugin_add) |
|
409 |
{
|
|
410 |
tokenize(opt_plugin_add, plugin_list, ",", true); |
|
411 |
}
|
|
412 |
||
413 |
if (opt_plugin_remove) |
|
414 |
{
|
|
415 |
vector<string> plugins_to_remove; |
|
416 |
tokenize(opt_plugin_remove, plugins_to_remove, ",", true); |
|
417 |
plugin_prune_list(plugin_list, plugins_to_remove); |
|
1530.2.3
by Monty Taylor
Changed the builtin plugin code path to work exactly the same as dynamic. |
418 |
plugin_prune_list(builtin_list, plugins_to_remove); |
419 |
}
|
|
420 |
||
421 |
||
422 |
/*
|
|
423 |
First we register builtin plugins
|
|
424 |
*/
|
|
425 |
const set<string> builtin_list_set(builtin_list.begin(), builtin_list.end()); |
|
426 |
load_failed= plugin_load_list(registry, &tmp_root, argc, argv, |
|
427 |
builtin_list_set, true); |
|
428 |
if (load_failed) |
|
429 |
{
|
|
430 |
tmp_root.free_root(MYF(0)); |
|
431 |
return true; |
|
1283.1.5
by Monty Taylor
Added --plugin-remove option, which prunes plugins from the list of plugins |
432 |
}
|
1377.3.11
by Monty Taylor
Suppress duplicate plugin names. |
433 |
|
434 |
/* Uniquify the list */
|
|
435 |
const set<string> plugin_list_set(plugin_list.begin(), plugin_list.end()); |
|
1283.1.5
by Monty Taylor
Added --plugin-remove option, which prunes plugins from the list of plugins |
436 |
|
1
by brian
clean slate |
437 |
/* Register all dynamic plugins */
|
1283.1.5
by Monty Taylor
Added --plugin-remove option, which prunes plugins from the list of plugins |
438 |
load_failed= plugin_load_list(registry, &tmp_root, argc, argv, |
1377.3.11
by Monty Taylor
Suppress duplicate plugin names. |
439 |
plugin_list_set); |
1241.10.4
by Monty Taylor
Actually throw errors on failure to init plugins. |
440 |
if (load_failed) |
441 |
{
|
|
1487
by Brian Aker
More updates for memory::Root |
442 |
tmp_root.free_root(MYF(0)); |
1241.10.4
by Monty Taylor
Actually throw errors on failure to init plugins. |
443 |
return true; |
1
by brian
clean slate |
444 |
}
|
445 |
||
1241.10.2
by Monty Taylor
Added support for embedding the drizzle version number in the plugin file. |
446 |
if (skip_init) |
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
447 |
{
|
1487
by Brian Aker
More updates for memory::Root |
448 |
tmp_root.free_root(MYF(0)); |
1241.10.4
by Monty Taylor
Actually throw errors on failure to init plugins. |
449 |
return false; |
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
450 |
}
|
1
by brian
clean slate |
451 |
|
452 |
/*
|
|
453 |
Now we initialize all remaining plugins
|
|
454 |
*/
|
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
455 |
std::map<std::string, module::Module *>::const_iterator modules= |
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
456 |
registry.getModulesMap().begin(); |
457 |
||
458 |
while (modules != registry.getModulesMap().end()) |
|
1
by brian
clean slate |
459 |
{
|
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
460 |
module= (*modules).second; |
461 |
++modules; |
|
1192.2.3
by Monty Taylor
Renamed plugin::Handle to plugin::Module for clarity. |
462 |
if (module->isInited == false) |
1
by brian
clean slate |
463 |
{
|
1192.2.3
by Monty Taylor
Renamed plugin::Handle to plugin::Module for clarity. |
464 |
plugin_initialize_vars(module); |
1119.1.1
by Monty Taylor
--help doesn't need --datadir to work. |
465 |
|
1192.2.3
by Monty Taylor
Renamed plugin::Handle to plugin::Module for clarity. |
466 |
if (plugin_initialize(registry, module)) |
1324.2.3
by Monty Taylor
Remove plugin deinit. |
467 |
delete_module(module); |
1
by brian
clean slate |
468 |
}
|
469 |
}
|
|
470 |
||
471 |
||
1487
by Brian Aker
More updates for memory::Root |
472 |
tmp_root.free_root(MYF(0)); |
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
473 |
|
1241.10.4
by Monty Taylor
Actually throw errors on failure to init plugins. |
474 |
return false; |
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
475 |
}
|
476 |
||
1283.1.5
by Monty Taylor
Added --plugin-remove option, which prunes plugins from the list of plugins |
477 |
class PrunePlugin : |
478 |
public unary_function<string, bool> |
|
479 |
{
|
|
480 |
const string to_match; |
|
481 |
PrunePlugin(); |
|
482 |
PrunePlugin& operator=(const PrunePlugin&); |
|
483 |
public: |
|
484 |
explicit PrunePlugin(const string &match_in) : |
|
485 |
to_match(match_in) |
|
486 |
{ } |
|
487 |
||
488 |
result_type operator()(const string &match_against) |
|
489 |
{
|
|
490 |
return match_against == to_match; |
|
491 |
}
|
|
492 |
};
|
|
493 |
||
494 |
static void plugin_prune_list(vector<string> &plugin_list, |
|
495 |
const vector<string> &plugins_to_remove) |
|
496 |
{
|
|
497 |
for (vector<string>::const_iterator iter= plugins_to_remove.begin(); |
|
498 |
iter != plugins_to_remove.end(); |
|
499 |
++iter) |
|
500 |
{
|
|
501 |
plugin_list.erase(remove_if(plugin_list.begin(), |
|
502 |
plugin_list.end(), |
|
503 |
PrunePlugin(*iter)), |
|
504 |
plugin_list.end()); |
|
505 |
}
|
|
506 |
}
|
|
1
by brian
clean slate |
507 |
|
508 |
/*
|
|
509 |
called only by plugin_init()
|
|
510 |
*/
|
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
511 |
static bool plugin_load_list(module::Registry ®istry, |
1253.1.3
by Monty Taylor
MEM_ROOT == memory::Root |
512 |
memory::Root *tmp_root, int *argc, char **argv, |
1530.2.3
by Monty Taylor
Changed the builtin plugin code path to work exactly the same as dynamic. |
513 |
const set<string> &plugin_list, |
514 |
bool builtin) |
|
1
by brian
clean slate |
515 |
{
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
516 |
module::Library *library= NULL; |
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
517 |
|
1377.3.11
by Monty Taylor
Suppress duplicate plugin names. |
518 |
for (set<string>::const_iterator iter= plugin_list.begin(); |
1283.1.5
by Monty Taylor
Added --plugin-remove option, which prunes plugins from the list of plugins |
519 |
iter != plugin_list.end(); |
520 |
++iter) |
|
1
by brian
clean slate |
521 |
{
|
1283.1.5
by Monty Taylor
Added --plugin-remove option, which prunes plugins from the list of plugins |
522 |
const string plugin_name(*iter); |
1530.2.4
by Monty Taylor
Fixed style catches from Jay. |
523 |
|
524 |
library= registry.addLibrary(plugin_name, builtin); |
|
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
525 |
if (library == NULL) |
526 |
{
|
|
527 |
errmsg_printf(ERRMSG_LVL_ERROR, |
|
1284.2.1
by Monty Taylor
Add a fatal error if a plugin has a name which has already been registered. |
528 |
_("Couldn't load plugin library named '%s'.\n"), |
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
529 |
plugin_name.c_str()); |
530 |
return true; |
|
531 |
}
|
|
532 |
||
1487
by Brian Aker
More updates for memory::Root |
533 |
tmp_root->free_root(MYF(memory::MARK_BLOCKS_FREE)); |
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
534 |
if (plugin_add(registry, tmp_root, library, argc, argv)) |
535 |
{
|
|
536 |
registry.removeLibrary(plugin_name); |
|
537 |
errmsg_printf(ERRMSG_LVL_ERROR, |
|
1284.2.1
by Monty Taylor
Add a fatal error if a plugin has a name which has already been registered. |
538 |
_("Couldn't load plugin named '%s'.\n"), |
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
539 |
plugin_name.c_str()); |
540 |
return true; |
|
541 |
||
542 |
}
|
|
1
by brian
clean slate |
543 |
}
|
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
544 |
return false; |
1
by brian
clean slate |
545 |
}
|
546 |
||
547 |
||
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
548 |
void module_shutdown(module::Registry ®istry) |
1
by brian
clean slate |
549 |
{
|
550 |
||
551 |
if (initialized) |
|
552 |
{
|
|
553 |
reap_needed= true; |
|
554 |
||
1110.1.3
by Monty Taylor
Added ListenHandler as a member of PluginRegistry. |
555 |
reap_plugins(registry); |
962.1.6
by Brian Aker
Cut down on shutdown loop of plugins (cutting stuff out in order to simplify |
556 |
unlock_variables(NULL, &global_system_variables); |
557 |
unlock_variables(NULL, &max_system_variables); |
|
1
by brian
clean slate |
558 |
|
559 |
cleanup_variables(NULL, &global_system_variables); |
|
560 |
cleanup_variables(NULL, &max_system_variables); |
|
561 |
||
562 |
initialized= 0; |
|
563 |
}
|
|
564 |
||
565 |
/* Dispose of the memory */
|
|
566 |
||
567 |
hash_free(&bookmark_hash); |
|
1487
by Brian Aker
More updates for memory::Root |
568 |
plugin_mem_root.free_root(MYF(0)); |
1
by brian
clean slate |
569 |
|
570 |
global_variables_dynamic_size= 0; |
|
571 |
}
|
|
572 |
||
573 |
/****************************************************************************
|
|
574 |
Internal type declarations for variables support
|
|
575 |
****************************************************************************/
|
|
576 |
||
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
577 |
#undef DRIZZLE_SYSVAR_NAME
|
578 |
#define DRIZZLE_SYSVAR_NAME(name) name
|
|
1
by brian
clean slate |
579 |
#define PLUGIN_VAR_TYPEMASK 0x007f
|
580 |
||
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
581 |
static const uint32_t EXTRA_OPTIONS= 1; /* handle the NULL option */ |
1
by brian
clean slate |
582 |
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
583 |
typedef DECLARE_DRIZZLE_SYSVAR_BASIC(sysvar_bool_t, bool); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
584 |
typedef DECLARE_DRIZZLE_SessionVAR_BASIC(sessionvar_bool_t, bool); |
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
585 |
typedef DECLARE_DRIZZLE_SYSVAR_BASIC(sysvar_str_t, char *); |
520.1.22
by Brian Aker
Second pass of thd cleanup |
586 |
typedef DECLARE_DRIZZLE_SessionVAR_BASIC(sessionvar_str_t, char *); |
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
587 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
588 |
typedef DECLARE_DRIZZLE_SessionVAR_TYPELIB(sessionvar_enum_t, unsigned long); |
589 |
typedef DECLARE_DRIZZLE_SessionVAR_TYPELIB(sessionvar_set_t, uint64_t); |
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
590 |
|
591 |
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_int_t, int); |
|
592 |
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_long_t, long); |
|
593 |
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_int64_t_t, int64_t); |
|
594 |
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_uint_t, uint); |
|
595 |
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_ulong_t, ulong); |
|
596 |
typedef DECLARE_DRIZZLE_SYSVAR_SIMPLE(sysvar_uint64_t_t, uint64_t); |
|
597 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
598 |
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_int_t, int); |
599 |
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_long_t, long); |
|
600 |
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_int64_t_t, int64_t); |
|
601 |
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_uint_t, uint); |
|
602 |
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_ulong_t, ulong); |
|
603 |
typedef DECLARE_DRIZZLE_SessionVAR_SIMPLE(sessionvar_uint64_t_t, uint64_t); |
|
1
by brian
clean slate |
604 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
605 |
typedef bool *(*mysql_sys_var_ptr_p)(Session* a_session, int offset); |
1
by brian
clean slate |
606 |
|
607 |
||
608 |
/****************************************************************************
|
|
609 |
default variable data check and update functions
|
|
610 |
****************************************************************************/
|
|
611 |
||
1228.1.5
by Monty Taylor
Merged in some naming things. |
612 |
static int check_func_bool(Session *, drizzle_sys_var *var, |
613 |
void *save, drizzle_value *value) |
|
1
by brian
clean slate |
614 |
{
|
615 |
char buff[STRING_BUFFER_USUAL_SIZE]; |
|
616 |
const char *strvalue= "NULL", *str; |
|
617 |
int result, length; |
|
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
618 |
int64_t tmp; |
1
by brian
clean slate |
619 |
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
620 |
if (value->value_type(value) == DRIZZLE_VALUE_TYPE_STRING) |
1
by brian
clean slate |
621 |
{
|
622 |
length= sizeof(buff); |
|
623 |
if (!(str= value->val_str(value, buff, &length)) || |
|
624 |
(result= find_type(&bool_typelib, str, length, 1)-1) < 0) |
|
625 |
{
|
|
626 |
if (str) |
|
627 |
strvalue= str; |
|
628 |
goto err; |
|
629 |
}
|
|
630 |
}
|
|
631 |
else
|
|
632 |
{
|
|
633 |
if (value->val_int(value, &tmp) < 0) |
|
634 |
goto err; |
|
635 |
if (tmp > 1) |
|
636 |
{
|
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
637 |
internal::llstr(tmp, buff); |
1
by brian
clean slate |
638 |
strvalue= buff; |
639 |
goto err; |
|
640 |
}
|
|
641 |
result= (int) tmp; |
|
642 |
}
|
|
643 |
*(int*)save= -result; |
|
644 |
return 0; |
|
645 |
err: |
|
646 |
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->name, strvalue); |
|
647 |
return 1; |
|
648 |
}
|
|
649 |
||
650 |
||
1228.1.5
by Monty Taylor
Merged in some naming things. |
651 |
static int check_func_int(Session *session, drizzle_sys_var *var, |
652 |
void *save, drizzle_value *value) |
|
1
by brian
clean slate |
653 |
{
|
143
by Brian Aker
Bool cleanup. |
654 |
bool fixed; |
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
655 |
int64_t tmp; |
1410.3.4
by Djellel E. Difallah
update references to old my_'s |
656 |
struct option options; |
1
by brian
clean slate |
657 |
value->val_int(value, &tmp); |
658 |
plugin_opt_set_limits(&options, var); |
|
659 |
||
660 |
if (var->flags & PLUGIN_VAR_UNSIGNED) |
|
895
by Brian Aker
Completion (?) of uint conversion. |
661 |
*(uint32_t *)save= (uint32_t) getopt_ull_limit_value((uint64_t) tmp, &options, |
1
by brian
clean slate |
662 |
&fixed); |
663 |
else
|
|
664 |
*(int *)save= (int) getopt_ll_limit_value(tmp, &options, &fixed); |
|
665 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
666 |
return throw_bounds_warning(session, fixed, var->flags & PLUGIN_VAR_UNSIGNED, |
152
by Brian Aker
longlong replacement |
667 |
var->name, (int64_t) tmp); |
1
by brian
clean slate |
668 |
}
|
669 |
||
670 |
||
1228.1.5
by Monty Taylor
Merged in some naming things. |
671 |
static int check_func_long(Session *session, drizzle_sys_var *var, |
672 |
void *save, drizzle_value *value) |
|
1
by brian
clean slate |
673 |
{
|
143
by Brian Aker
Bool cleanup. |
674 |
bool fixed; |
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
675 |
int64_t tmp; |
1410.3.4
by Djellel E. Difallah
update references to old my_'s |
676 |
struct option options; |
1
by brian
clean slate |
677 |
value->val_int(value, &tmp); |
678 |
plugin_opt_set_limits(&options, var); |
|
679 |
||
680 |
if (var->flags & PLUGIN_VAR_UNSIGNED) |
|
151
by Brian Aker
Ulonglong to uint64_t |
681 |
*(ulong *)save= (ulong) getopt_ull_limit_value((uint64_t) tmp, &options, |
1
by brian
clean slate |
682 |
&fixed); |
683 |
else
|
|
684 |
*(long *)save= (long) getopt_ll_limit_value(tmp, &options, &fixed); |
|
685 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
686 |
return throw_bounds_warning(session, fixed, var->flags & PLUGIN_VAR_UNSIGNED, |
152
by Brian Aker
longlong replacement |
687 |
var->name, (int64_t) tmp); |
1
by brian
clean slate |
688 |
}
|
689 |
||
690 |
||
1228.1.5
by Monty Taylor
Merged in some naming things. |
691 |
static int check_func_int64_t(Session *session, drizzle_sys_var *var, |
692 |
void *save, drizzle_value *value) |
|
1
by brian
clean slate |
693 |
{
|
143
by Brian Aker
Bool cleanup. |
694 |
bool fixed; |
53.2.2
by Monty Taylor
Updated everything that needs updating to compile with -std=gnu99 -pedantic |
695 |
int64_t tmp; |
1410.3.4
by Djellel E. Difallah
update references to old my_'s |
696 |
struct option options; |
1
by brian
clean slate |
697 |
value->val_int(value, &tmp); |
698 |
plugin_opt_set_limits(&options, var); |
|
699 |
||
700 |
if (var->flags & PLUGIN_VAR_UNSIGNED) |
|
151
by Brian Aker
Ulonglong to uint64_t |
701 |
*(uint64_t *)save= getopt_ull_limit_value((uint64_t) tmp, &options, |
1
by brian
clean slate |
702 |
&fixed); |
703 |
else
|
|
152
by Brian Aker
longlong replacement |
704 |
*(int64_t *)save= getopt_ll_limit_value(tmp, &options, &fixed); |
1
by brian
clean slate |
705 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
706 |
return throw_bounds_warning(session, fixed, var->flags & PLUGIN_VAR_UNSIGNED, |
152
by Brian Aker
longlong replacement |
707 |
var->name, (int64_t) tmp); |
1
by brian
clean slate |
708 |
}
|
709 |
||
1228.1.5
by Monty Taylor
Merged in some naming things. |
710 |
static int check_func_str(Session *session, drizzle_sys_var *, |
711 |
void *save, drizzle_value *value) |
|
1
by brian
clean slate |
712 |
{
|
713 |
char buff[STRING_BUFFER_USUAL_SIZE]; |
|
714 |
const char *str; |
|
715 |
int length; |
|
716 |
||
717 |
length= sizeof(buff); |
|
718 |
if ((str= value->val_str(value, buff, &length))) |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
719 |
str= session->strmake(str, length); |
1
by brian
clean slate |
720 |
*(const char**)save= str; |
721 |
return 0; |
|
722 |
}
|
|
723 |
||
724 |
||
1228.1.5
by Monty Taylor
Merged in some naming things. |
725 |
static void update_func_bool(Session *, drizzle_sys_var *, |
1
by brian
clean slate |
726 |
void *tgt, const void *save) |
727 |
{
|
|
199
by Brian Aker
my_bool... |
728 |
*(bool *) tgt= *(int *) save ? 1 : 0; |
1
by brian
clean slate |
729 |
}
|
730 |
||
731 |
||
1228.1.5
by Monty Taylor
Merged in some naming things. |
732 |
static void update_func_int(Session *, drizzle_sys_var *, |
1
by brian
clean slate |
733 |
void *tgt, const void *save) |
734 |
{
|
|
735 |
*(int *)tgt= *(int *) save; |
|
736 |
}
|
|
737 |
||
738 |
||
1228.1.5
by Monty Taylor
Merged in some naming things. |
739 |
static void update_func_long(Session *, drizzle_sys_var *, |
1
by brian
clean slate |
740 |
void *tgt, const void *save) |
741 |
{
|
|
742 |
*(long *)tgt= *(long *) save; |
|
743 |
}
|
|
744 |
||
745 |
||
1228.1.5
by Monty Taylor
Merged in some naming things. |
746 |
static void update_func_int64_t(Session *, drizzle_sys_var *, |
77.1.46
by Monty Taylor
Finished the warnings work! |
747 |
void *tgt, const void *save) |
1
by brian
clean slate |
748 |
{
|
152
by Brian Aker
longlong replacement |
749 |
*(int64_t *)tgt= *(uint64_t *) save; |
1
by brian
clean slate |
750 |
}
|
751 |
||
752 |
||
1228.1.5
by Monty Taylor
Merged in some naming things. |
753 |
static void update_func_str(Session *, drizzle_sys_var *var, |
1
by brian
clean slate |
754 |
void *tgt, const void *save) |
755 |
{
|
|
756 |
char *old= *(char **) tgt; |
|
757 |
*(char **)tgt= *(char **) save; |
|
758 |
if (var->flags & PLUGIN_VAR_MEMALLOC) |
|
759 |
{
|
|
656.1.19
by Monty Taylor
Removed my_strdup from drizzled/ |
760 |
*(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. |
761 |
free(old); |
656.1.52
by Monty Taylor
Added more return value checks. |
762 |
/*
|
763 |
* There isn't a _really_ good thing to do here until this whole set_var
|
|
764 |
* mess gets redesigned
|
|
765 |
*/
|
|
766 |
if (tgt == NULL) |
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
767 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Out of memory.")); |
656.1.52
by Monty Taylor
Added more return value checks. |
768 |
|
1
by brian
clean slate |
769 |
}
|
770 |
}
|
|
771 |
||
772 |
||
773 |
/****************************************************************************
|
|
774 |
System Variables support
|
|
775 |
****************************************************************************/
|
|
776 |
||
777 |
||
970.1.1
by Brian Aker
Removed dead passed variables. |
778 |
sys_var *find_sys_var(Session *, const char *str, uint32_t length) |
1
by brian
clean slate |
779 |
{
|
780 |
sys_var *var; |
|
781 |
sys_var_pluginvar *pi= NULL; |
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
782 |
module::Module *module; |
1
by brian
clean slate |
783 |
|
658
by Brian Aker
Part removal of my_pthread.h |
784 |
pthread_rwlock_rdlock(&LOCK_system_variables_hash); |
1
by brian
clean slate |
785 |
if ((var= intern_find_sys_var(str, length, false)) && |
786 |
(pi= var->cast_pluginvar())) |
|
787 |
{
|
|
658
by Brian Aker
Part removal of my_pthread.h |
788 |
pthread_rwlock_unlock(&LOCK_system_variables_hash); |
1192.2.3
by Monty Taylor
Renamed plugin::Handle to plugin::Module for clarity. |
789 |
if (!(module= pi->plugin)) |
1
by brian
clean slate |
790 |
var= NULL; /* failed to lock it, it must be uninstalling */ |
1192.2.3
by Monty Taylor
Renamed plugin::Handle to plugin::Module for clarity. |
791 |
else if (module->isInited == false) |
1
by brian
clean slate |
792 |
{
|
793 |
var= NULL; |
|
794 |
}
|
|
795 |
}
|
|
796 |
else
|
|
658
by Brian Aker
Part removal of my_pthread.h |
797 |
pthread_rwlock_unlock(&LOCK_system_variables_hash); |
1
by brian
clean slate |
798 |
|
799 |
/*
|
|
800 |
If the variable exists but the plugin it is associated with is not ready
|
|
801 |
then the intern_plugin_lock did not raise an error, so we do it here.
|
|
802 |
*/
|
|
803 |
if (pi && !var) |
|
804 |
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 |
805 |
return(var); |
1
by brian
clean slate |
806 |
}
|
807 |
||
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
808 |
static const string make_bookmark_name(const string &plugin, const char *name, int flags) |
809 |
{
|
|
810 |
/* Embed the flags into the first char of the string */
|
|
811 |
string varname(1, static_cast<char>(flags & PLUGIN_VAR_TYPEMASK)); |
|
812 |
varname.append(plugin); |
|
813 |
varname.push_back('_'); |
|
814 |
varname.append(name); |
|
815 |
||
816 |
for (string::iterator p= varname.begin() + 1; p != varname.end(); ++p) |
|
817 |
{
|
|
818 |
if (*p == '-') |
|
819 |
{
|
|
820 |
*p= '_'; |
|
821 |
}
|
|
822 |
}
|
|
823 |
return varname; |
|
824 |
}
|
|
1
by brian
clean slate |
825 |
|
826 |
/*
|
|
827 |
called by register_var, construct_options and test_plugin_options.
|
|
828 |
Returns the 'bookmark' for the named variable.
|
|
829 |
LOCK_system_variables_hash should be at least read locked
|
|
830 |
*/
|
|
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
831 |
static st_bookmark *find_bookmark(const string &plugin, const char *name, int flags) |
1
by brian
clean slate |
832 |
{
|
833 |
st_bookmark *result= NULL; |
|
834 |
||
520.1.21
by Brian Aker
THD -> Session rename |
835 |
if (!(flags & PLUGIN_VAR_SessionLOCAL)) |
1
by brian
clean slate |
836 |
return NULL; |
837 |
||
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
838 |
const string varname(make_bookmark_name(plugin, name, flags)); |
839 |
||
1
by brian
clean slate |
840 |
|
841 |
result= (st_bookmark*) hash_search(&bookmark_hash, |
|
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
842 |
(const unsigned char*) varname.c_str(), varname.size() - 1); |
1
by brian
clean slate |
843 |
|
844 |
return result; |
|
845 |
}
|
|
846 |
||
847 |
||
848 |
/*
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
849 |
returns a bookmark for session-local variables, creating if neccessary.
|
850 |
returns null for non session-local variables.
|
|
1
by brian
clean slate |
851 |
Requires that a write lock is obtained on LOCK_system_variables_hash
|
852 |
*/
|
|
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
853 |
static st_bookmark *register_var(const string &plugin, const char *name, |
1
by brian
clean slate |
854 |
int flags) |
855 |
{
|
|
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
856 |
if (!(flags & PLUGIN_VAR_SessionLOCAL)) |
857 |
return NULL; |
|
858 |
||
859 |
uint32_t size= 0, offset, new_size; |
|
1
by brian
clean slate |
860 |
st_bookmark *result; |
861 |
||
862 |
switch (flags & PLUGIN_VAR_TYPEMASK) { |
|
863 |
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 |
864 |
size= ALIGN_SIZE(sizeof(bool)); |
1
by brian
clean slate |
865 |
break; |
866 |
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 |
867 |
size= ALIGN_SIZE(sizeof(int)); |
1
by brian
clean slate |
868 |
break; |
869 |
case PLUGIN_VAR_LONG: |
|
937.2.12
by Stewart Smith
ensure correct alignment of all plugin variables. Manifesting as innodb_mysql test failure with SIGBUS on Sparc |
870 |
size= ALIGN_SIZE(sizeof(long)); |
1
by brian
clean slate |
871 |
break; |
872 |
case PLUGIN_VAR_LONGLONG: |
|
937.2.12
by Stewart Smith
ensure correct alignment of all plugin variables. Manifesting as innodb_mysql test failure with SIGBUS on Sparc |
873 |
size= ALIGN_SIZE(sizeof(uint64_t)); |
1
by brian
clean slate |
874 |
break; |
875 |
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 |
876 |
size= ALIGN_SIZE(sizeof(char*)); |
1
by brian
clean slate |
877 |
break; |
878 |
default: |
|
51.1.62
by Jay Pipes
Removed/replaced BUG symbols and standardized TRUE/FALSE |
879 |
assert(0); |
1
by brian
clean slate |
880 |
return NULL; |
881 |
};
|
|
882 |
||
883 |
||
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
884 |
if (!(result= find_bookmark(plugin, name, flags))) |
1
by brian
clean slate |
885 |
{
|
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
886 |
const string varname(make_bookmark_name(plugin, name, flags)); |
887 |
||
1485
by Brian Aker
Updates to confine memroot |
888 |
result= static_cast<st_bookmark*>(plugin_mem_root.alloc_root(sizeof(struct st_bookmark) + varname.size() + 1)); |
1283.1.3
by Monty Taylor
Hrm. Sometimes initializing memory is nice. |
889 |
memset(result->key, 0, varname.size()+1); |
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
890 |
memcpy(result->key, varname.c_str(), varname.size()); |
891 |
result->name_len= varname.size() - 2; |
|
1
by brian
clean slate |
892 |
result->offset= -1; |
893 |
||
51.1.62
by Jay Pipes
Removed/replaced BUG symbols and standardized TRUE/FALSE |
894 |
assert(size && !(size & (size-1))); /* must be power of 2 */ |
1
by brian
clean slate |
895 |
|
896 |
offset= global_system_variables.dynamic_variables_size; |
|
897 |
offset= (offset + size - 1) & ~(size - 1); |
|
898 |
result->offset= (int) offset; |
|
899 |
||
900 |
new_size= (offset + size + 63) & ~63; |
|
901 |
||
902 |
if (new_size > global_variables_dynamic_size) |
|
903 |
{
|
|
656.1.46
by Monty Taylor
More malloc return cleanups. |
904 |
char* tmpptr= NULL; |
905 |
if (!(tmpptr= |
|
906 |
(char *)realloc(global_system_variables.dynamic_variables_ptr, |
|
907 |
new_size))) |
|
908 |
return NULL; |
|
909 |
global_system_variables.dynamic_variables_ptr= tmpptr; |
|
910 |
tmpptr= NULL; |
|
911 |
if (!(tmpptr= |
|
912 |
(char *)realloc(max_system_variables.dynamic_variables_ptr, |
|
913 |
new_size))) |
|
914 |
return NULL; |
|
915 |
max_system_variables.dynamic_variables_ptr= tmpptr; |
|
656.1.26
by Monty Taylor
Finally removed all of the my_malloc stuff. |
916 |
|
1
by brian
clean slate |
917 |
/*
|
918 |
Clear the new variable value space. This is required for string
|
|
919 |
variables. If their value is non-NULL, it must point to a valid
|
|
920 |
string.
|
|
921 |
*/
|
|
212.6.1
by Mats Kindahl
Replacing all bzero() calls with memset() calls and removing the bzero.c file. |
922 |
memset(global_system_variables.dynamic_variables_ptr + |
923 |
global_variables_dynamic_size, 0, |
|
924 |
new_size - global_variables_dynamic_size); |
|
925 |
memset(max_system_variables.dynamic_variables_ptr + |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
926 |
global_variables_dynamic_size, 0, |
212.6.1
by Mats Kindahl
Replacing all bzero() calls with memset() calls and removing the bzero.c file. |
927 |
new_size - global_variables_dynamic_size); |
1
by brian
clean slate |
928 |
global_variables_dynamic_size= new_size; |
929 |
}
|
|
930 |
||
931 |
global_system_variables.dynamic_variables_head= offset; |
|
932 |
max_system_variables.dynamic_variables_head= offset; |
|
933 |
global_system_variables.dynamic_variables_size= offset + size; |
|
934 |
max_system_variables.dynamic_variables_size= offset + size; |
|
935 |
global_system_variables.dynamic_variables_version++; |
|
936 |
max_system_variables.dynamic_variables_version++; |
|
937 |
||
938 |
result->version= global_system_variables.dynamic_variables_version; |
|
939 |
||
940 |
/* this should succeed because we have already checked if a dup exists */
|
|
481
by Brian Aker
Remove all of uchar. |
941 |
if (my_hash_insert(&bookmark_hash, (unsigned char*) result)) |
1
by brian
clean slate |
942 |
{
|
943 |
fprintf(stderr, "failed to add placeholder to hash"); |
|
51.1.62
by Jay Pipes
Removed/replaced BUG symbols and standardized TRUE/FALSE |
944 |
assert(0); |
1
by brian
clean slate |
945 |
}
|
946 |
}
|
|
947 |
return result; |
|
948 |
}
|
|
949 |
||
950 |
||
951 |
/*
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
952 |
returns a pointer to the memory which holds the session-local variable or
|
953 |
a pointer to the global variable if session==null.
|
|
1
by brian
clean slate |
954 |
If required, will sync with global variables if the requested variable
|
955 |
has not yet been allocated in the current thread.
|
|
956 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
957 |
static unsigned char *intern_sys_var_ptr(Session* session, int offset, bool global_lock) |
1
by brian
clean slate |
958 |
{
|
51.1.62
by Jay Pipes
Removed/replaced BUG symbols and standardized TRUE/FALSE |
959 |
assert(offset >= 0); |
895
by Brian Aker
Completion (?) of uint conversion. |
960 |
assert((uint32_t)offset <= global_system_variables.dynamic_variables_head); |
1
by brian
clean slate |
961 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
962 |
if (!session) |
481
by Brian Aker
Remove all of uchar. |
963 |
return (unsigned char*) global_system_variables.dynamic_variables_ptr + offset; |
1
by brian
clean slate |
964 |
|
965 |
/*
|
|
966 |
dynamic_variables_head points to the largest valid offset
|
|
967 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
968 |
if (!session->variables.dynamic_variables_ptr || |
895
by Brian Aker
Completion (?) of uint conversion. |
969 |
(uint32_t)offset > session->variables.dynamic_variables_head) |
1
by brian
clean slate |
970 |
{
|
482
by Brian Aker
Remove uint. |
971 |
uint32_t idx; |
1
by brian
clean slate |
972 |
|
658
by Brian Aker
Part removal of my_pthread.h |
973 |
pthread_rwlock_rdlock(&LOCK_system_variables_hash); |
1
by brian
clean slate |
974 |
|
656.1.46
by Monty Taylor
More malloc return cleanups. |
975 |
char *tmpptr= NULL; |
976 |
if (!(tmpptr= (char *)realloc(session->variables.dynamic_variables_ptr, |
|
977 |
global_variables_dynamic_size))) |
|
978 |
return NULL; |
|
979 |
session->variables.dynamic_variables_ptr= tmpptr; |
|
1
by brian
clean slate |
980 |
|
981 |
if (global_lock) |
|
982 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
983 |
||
1241.9.62
by Monty Taylor
Removed plugin/myisam/myisam.h from session.h |
984 |
//safe_mutex_assert_owner(&LOCK_global_system_variables);
|
1
by brian
clean slate |
985 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
986 |
memcpy(session->variables.dynamic_variables_ptr + |
987 |
session->variables.dynamic_variables_size, |
|
1
by brian
clean slate |
988 |
global_system_variables.dynamic_variables_ptr + |
520.1.22
by Brian Aker
Second pass of thd cleanup |
989 |
session->variables.dynamic_variables_size, |
1
by brian
clean slate |
990 |
global_system_variables.dynamic_variables_size - |
520.1.22
by Brian Aker
Second pass of thd cleanup |
991 |
session->variables.dynamic_variables_size); |
1
by brian
clean slate |
992 |
|
993 |
/*
|
|
994 |
now we need to iterate through any newly copied 'defaults'
|
|
995 |
and if it is a string type with MEMALLOC flag, we need to strdup
|
|
996 |
*/
|
|
997 |
for (idx= 0; idx < bookmark_hash.records; idx++) |
|
998 |
{
|
|
999 |
sys_var_pluginvar *pi; |
|
1000 |
sys_var *var; |
|
1001 |
st_bookmark *v= (st_bookmark*) hash_element(&bookmark_hash,idx); |
|
1002 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1003 |
if (v->version <= session->variables.dynamic_variables_version || |
1
by brian
clean slate |
1004 |
!(var= intern_find_sys_var(v->key + 1, v->name_len, true)) || |
1005 |
!(pi= var->cast_pluginvar()) || |
|
1006 |
v->key[0] != (pi->plugin_var->flags & PLUGIN_VAR_TYPEMASK)) |
|
1007 |
continue; |
|
1008 |
||
1009 |
/* Here we do anything special that may be required of the data types */
|
|
1010 |
||
1011 |
if ((pi->plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR && |
|
1012 |
pi->plugin_var->flags & PLUGIN_VAR_MEMALLOC) |
|
1013 |
{
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1014 |
char **pp= (char**) (session->variables.dynamic_variables_ptr + |
1
by brian
clean slate |
1015 |
*(int*)(pi->plugin_var + 1)); |
1016 |
if ((*pp= *(char**) (global_system_variables.dynamic_variables_ptr + |
|
1017 |
*(int*)(pi->plugin_var + 1)))) |
|
656.1.19
by Monty Taylor
Removed my_strdup from drizzled/ |
1018 |
*pp= strdup(*pp); |
656.1.52
by Monty Taylor
Added more return value checks. |
1019 |
if (*pp == NULL) |
1020 |
return NULL; |
|
1
by brian
clean slate |
1021 |
}
|
1022 |
}
|
|
1023 |
||
1024 |
if (global_lock) |
|
1025 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
1026 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1027 |
session->variables.dynamic_variables_version= |
1
by brian
clean slate |
1028 |
global_system_variables.dynamic_variables_version; |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1029 |
session->variables.dynamic_variables_head= |
1
by brian
clean slate |
1030 |
global_system_variables.dynamic_variables_head; |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1031 |
session->variables.dynamic_variables_size= |
1
by brian
clean slate |
1032 |
global_system_variables.dynamic_variables_size; |
1033 |
||
658
by Brian Aker
Part removal of my_pthread.h |
1034 |
pthread_rwlock_unlock(&LOCK_system_variables_hash); |
1
by brian
clean slate |
1035 |
}
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1036 |
return (unsigned char*)session->variables.dynamic_variables_ptr + offset; |
1037 |
}
|
|
1038 |
||
1039 |
static bool *mysql_sys_var_ptr_bool(Session* a_session, int offset) |
|
1040 |
{
|
|
1041 |
return (bool *)intern_sys_var_ptr(a_session, offset, true); |
|
1042 |
}
|
|
1043 |
||
1044 |
static int *mysql_sys_var_ptr_int(Session* a_session, int offset) |
|
1045 |
{
|
|
1046 |
return (int *)intern_sys_var_ptr(a_session, offset, true); |
|
1047 |
}
|
|
1048 |
||
1049 |
static long *mysql_sys_var_ptr_long(Session* a_session, int offset) |
|
1050 |
{
|
|
1051 |
return (long *)intern_sys_var_ptr(a_session, offset, true); |
|
1052 |
}
|
|
1053 |
||
1054 |
static int64_t *mysql_sys_var_ptr_int64_t(Session* a_session, int offset) |
|
1055 |
{
|
|
1056 |
return (int64_t *)intern_sys_var_ptr(a_session, offset, true); |
|
1057 |
}
|
|
1058 |
||
1059 |
static char **mysql_sys_var_ptr_str(Session* a_session, int offset) |
|
1060 |
{
|
|
1061 |
return (char **)intern_sys_var_ptr(a_session, offset, true); |
|
1062 |
}
|
|
1063 |
||
1064 |
void plugin_sessionvar_init(Session *session) |
|
1065 |
{
|
|
971.1.21
by Monty Taylor
Store StorageEngine in system variables, rather than storage engine plugin. |
1066 |
session->variables.storage_engine= NULL; |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1067 |
cleanup_variables(session, &session->variables); |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
1068 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1069 |
session->variables= global_system_variables; |
971.1.21
by Monty Taylor
Store StorageEngine in system variables, rather than storage engine plugin. |
1070 |
session->variables.storage_engine= NULL; |
1
by brian
clean slate |
1071 |
|
1072 |
/* we are going to allocate these lazily */
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1073 |
session->variables.dynamic_variables_version= 0; |
1074 |
session->variables.dynamic_variables_size= 0; |
|
1075 |
session->variables.dynamic_variables_ptr= 0; |
|
1
by brian
clean slate |
1076 |
|
971.1.21
by Monty Taylor
Store StorageEngine in system variables, rather than storage engine plugin. |
1077 |
session->variables.storage_engine= global_system_variables.storage_engine; |
1
by brian
clean slate |
1078 |
}
|
1079 |
||
1080 |
||
1081 |
/*
|
|
1082 |
Unlocks all system variables which hold a reference
|
|
1083 |
*/
|
|
654
by Brian Aker
Remove unused (yet more) |
1084 |
static void unlock_variables(Session *, struct system_variables *vars) |
1
by brian
clean slate |
1085 |
{
|
971.1.21
by Monty Taylor
Store StorageEngine in system variables, rather than storage engine plugin. |
1086 |
vars->storage_engine= NULL; |
1
by brian
clean slate |
1087 |
}
|
1088 |
||
1089 |
||
1090 |
/*
|
|
1091 |
Frees memory used by system variables
|
|
1092 |
||
1093 |
Unlike plugin_vars_free_values() it frees all variables of all plugins,
|
|
1094 |
it's used on shutdown.
|
|
1095 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1096 |
static void cleanup_variables(Session *session, struct system_variables *vars) |
1
by brian
clean slate |
1097 |
{
|
1098 |
st_bookmark *v; |
|
1099 |
sys_var_pluginvar *pivar; |
|
1100 |
sys_var *var; |
|
1101 |
int flags; |
|
482
by Brian Aker
Remove uint. |
1102 |
uint32_t idx; |
1
by brian
clean slate |
1103 |
|
658
by Brian Aker
Part removal of my_pthread.h |
1104 |
pthread_rwlock_rdlock(&LOCK_system_variables_hash); |
1
by brian
clean slate |
1105 |
for (idx= 0; idx < bookmark_hash.records; idx++) |
1106 |
{
|
|
1107 |
v= (st_bookmark*) hash_element(&bookmark_hash, idx); |
|
1108 |
if (v->version > vars->dynamic_variables_version || |
|
1109 |
!(var= intern_find_sys_var(v->key + 1, v->name_len, true)) || |
|
1110 |
!(pivar= var->cast_pluginvar()) || |
|
1111 |
v->key[0] != (pivar->plugin_var->flags & PLUGIN_VAR_TYPEMASK)) |
|
1112 |
continue; |
|
1113 |
||
1114 |
flags= pivar->plugin_var->flags; |
|
1115 |
||
1116 |
if ((flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR && |
|
520.1.21
by Brian Aker
THD -> Session rename |
1117 |
flags & PLUGIN_VAR_SessionLOCAL && flags & PLUGIN_VAR_MEMALLOC) |
1
by brian
clean slate |
1118 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1119 |
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. |
1120 |
free(*ptr); |
1
by brian
clean slate |
1121 |
*ptr= NULL; |
1122 |
}
|
|
1123 |
}
|
|
658
by Brian Aker
Part removal of my_pthread.h |
1124 |
pthread_rwlock_unlock(&LOCK_system_variables_hash); |
1
by brian
clean slate |
1125 |
|
971.1.21
by Monty Taylor
Store StorageEngine in system variables, rather than storage engine plugin. |
1126 |
assert(vars->storage_engine == NULL); |
1
by brian
clean slate |
1127 |
|
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. |
1128 |
free(vars->dynamic_variables_ptr); |
1
by brian
clean slate |
1129 |
vars->dynamic_variables_ptr= NULL; |
1130 |
vars->dynamic_variables_size= 0; |
|
1131 |
vars->dynamic_variables_version= 0; |
|
1132 |
}
|
|
1133 |
||
1134 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1135 |
void plugin_sessionvar_cleanup(Session *session) |
1
by brian
clean slate |
1136 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1137 |
unlock_variables(session, &session->variables); |
1138 |
cleanup_variables(session, &session->variables); |
|
1
by brian
clean slate |
1139 |
}
|
1140 |
||
1141 |
||
1142 |
/**
|
|
1143 |
@brief Free values of thread variables of a plugin.
|
|
1144 |
||
1145 |
This must be called before a plugin is deleted. Otherwise its
|
|
1146 |
variables are no longer accessible and the value space is lost. Note
|
|
1147 |
that only string values with PLUGIN_VAR_MEMALLOC are allocated and
|
|
1148 |
must be freed.
|
|
1149 |
||
1150 |
@param[in] vars Chain of system variables of a plugin
|
|
1151 |
*/
|
|
1152 |
||
1153 |
static void plugin_vars_free_values(sys_var *vars) |
|
1154 |
{
|
|
1155 |
||
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. |
1156 |
for (sys_var *var= vars; var; var= var->getNext()) |
1
by brian
clean slate |
1157 |
{
|
1158 |
sys_var_pluginvar *piv= var->cast_pluginvar(); |
|
1159 |
if (piv && |
|
1160 |
((piv->plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR) && |
|
1161 |
(piv->plugin_var->flags & PLUGIN_VAR_MEMALLOC)) |
|
1162 |
{
|
|
1163 |
/* Free the string from global_system_variables. */
|
|
1164 |
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. |
1165 |
free(*valptr); |
1
by brian
clean slate |
1166 |
*valptr= NULL; |
1167 |
}
|
|
1168 |
}
|
|
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 |
1169 |
return; |
1
by brian
clean slate |
1170 |
}
|
1171 |
||
1172 |
||
1173 |
bool sys_var_pluginvar::check_update_type(Item_result type) |
|
1174 |
{
|
|
1175 |
if (is_readonly()) |
|
1176 |
return 1; |
|
1177 |
switch (plugin_var->flags & PLUGIN_VAR_TYPEMASK) { |
|
1178 |
case PLUGIN_VAR_INT: |
|
1179 |
case PLUGIN_VAR_LONG: |
|
1180 |
case PLUGIN_VAR_LONGLONG: |
|
1181 |
return type != INT_RESULT; |
|
1182 |
case PLUGIN_VAR_STR: |
|
1183 |
return type != STRING_RESULT; |
|
1184 |
default: |
|
1185 |
return 0; |
|
1186 |
}
|
|
1187 |
}
|
|
1188 |
||
1189 |
||
1190 |
SHOW_TYPE sys_var_pluginvar::show_type() |
|
1191 |
{
|
|
1192 |
switch (plugin_var->flags & PLUGIN_VAR_TYPEMASK) { |
|
1193 |
case PLUGIN_VAR_BOOL: |
|
1194 |
return SHOW_MY_BOOL; |
|
1195 |
case PLUGIN_VAR_INT: |
|
1196 |
return SHOW_INT; |
|
1197 |
case PLUGIN_VAR_LONG: |
|
1198 |
return SHOW_LONG; |
|
1199 |
case PLUGIN_VAR_LONGLONG: |
|
1200 |
return SHOW_LONGLONG; |
|
1201 |
case PLUGIN_VAR_STR: |
|
1202 |
return SHOW_CHAR_PTR; |
|
1203 |
default: |
|
51.1.62
by Jay Pipes
Removed/replaced BUG symbols and standardized TRUE/FALSE |
1204 |
assert(0); |
1
by brian
clean slate |
1205 |
return SHOW_UNDEF; |
1206 |
}
|
|
1207 |
}
|
|
1208 |
||
1209 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
1210 |
unsigned char* sys_var_pluginvar::real_value_ptr(Session *session, sql_var_t type) |
1
by brian
clean slate |
1211 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1212 |
assert(session || (type == OPT_GLOBAL)); |
520.1.21
by Brian Aker
THD -> Session rename |
1213 |
if (plugin_var->flags & PLUGIN_VAR_SessionLOCAL) |
1
by brian
clean slate |
1214 |
{
|
1215 |
if (type == OPT_GLOBAL) |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1216 |
session= NULL; |
1
by brian
clean slate |
1217 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1218 |
return intern_sys_var_ptr(session, *(int*) (plugin_var+1), false); |
1
by brian
clean slate |
1219 |
}
|
481
by Brian Aker
Remove all of uchar. |
1220 |
return *(unsigned char**) (plugin_var+1); |
1
by brian
clean slate |
1221 |
}
|
1222 |
||
1223 |
||
1224 |
TYPELIB* sys_var_pluginvar::plugin_var_typelib(void) |
|
1225 |
{
|
|
520.1.21
by Brian Aker
THD -> Session rename |
1226 |
switch (plugin_var->flags & (PLUGIN_VAR_TYPEMASK | PLUGIN_VAR_SessionLOCAL)) { |
1280.1.6
by Brian Aker
removw DRIZZLE_SYSVAR_ENUM |
1227 |
case PLUGIN_VAR_SessionLOCAL: |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1228 |
return ((sessionvar_enum_t *)plugin_var)->typelib; |
1
by brian
clean slate |
1229 |
default: |
1230 |
return NULL; |
|
1231 |
}
|
|
1232 |
return NULL; |
|
1233 |
}
|
|
1234 |
||
1235 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
1236 |
unsigned char* sys_var_pluginvar::value_ptr(Session *session, sql_var_t type, const LEX_STRING *) |
1
by brian
clean slate |
1237 |
{
|
481
by Brian Aker
Remove all of uchar. |
1238 |
unsigned char* result; |
1
by brian
clean slate |
1239 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1240 |
result= real_value_ptr(session, type); |
1
by brian
clean slate |
1241 |
|
1242 |
return result; |
|
1243 |
}
|
|
1244 |
||
1245 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1246 |
bool sys_var_pluginvar::check(Session *session, set_var *var) |
1
by brian
clean slate |
1247 |
{
|
1248 |
st_item_value_holder value; |
|
51.1.62
by Jay Pipes
Removed/replaced BUG symbols and standardized TRUE/FALSE |
1249 |
assert(is_readonly() || plugin_var->check); |
1
by brian
clean slate |
1250 |
|
1251 |
value.value_type= item_value_type; |
|
1252 |
value.val_str= item_val_str; |
|
1253 |
value.val_int= item_val_int; |
|
1254 |
value.val_real= item_val_real; |
|
1255 |
value.item= var->value; |
|
1256 |
||
1257 |
return is_readonly() || |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1258 |
plugin_var->check(session, plugin_var, &var->save_result, &value); |
1
by brian
clean slate |
1259 |
}
|
1260 |
||
1261 |
||
1273.13.24
by Brian Aker
Updating style, simplified code. |
1262 |
void sys_var_pluginvar::set_default(Session *session, sql_var_t type) |
1
by brian
clean slate |
1263 |
{
|
1264 |
const void *src; |
|
1265 |
void *tgt; |
|
1266 |
||
51.1.62
by Jay Pipes
Removed/replaced BUG symbols and standardized TRUE/FALSE |
1267 |
assert(is_readonly() || plugin_var->update); |
1
by brian
clean slate |
1268 |
|
1269 |
if (is_readonly()) |
|
1270 |
return; |
|
1271 |
||
1272 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1273 |
tgt= real_value_ptr(session, type); |
1
by brian
clean slate |
1274 |
src= ((void **) (plugin_var + 1) + 1); |
1275 |
||
520.1.21
by Brian Aker
THD -> Session rename |
1276 |
if (plugin_var->flags & PLUGIN_VAR_SessionLOCAL) |
1
by brian
clean slate |
1277 |
{
|
1278 |
if (type != OPT_GLOBAL) |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1279 |
src= real_value_ptr(session, OPT_GLOBAL); |
1
by brian
clean slate |
1280 |
else
|
1281 |
switch (plugin_var->flags & PLUGIN_VAR_TYPEMASK) { |
|
1282 |
case PLUGIN_VAR_INT: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1283 |
src= &((sessionvar_uint_t*) plugin_var)->def_val; |
1
by brian
clean slate |
1284 |
break; |
1285 |
case PLUGIN_VAR_LONG: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1286 |
src= &((sessionvar_ulong_t*) plugin_var)->def_val; |
1
by brian
clean slate |
1287 |
break; |
1288 |
case PLUGIN_VAR_LONGLONG: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1289 |
src= &((sessionvar_uint64_t_t*) plugin_var)->def_val; |
1
by brian
clean slate |
1290 |
break; |
1291 |
case PLUGIN_VAR_BOOL: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1292 |
src= &((sessionvar_bool_t*) plugin_var)->def_val; |
1
by brian
clean slate |
1293 |
break; |
1294 |
case PLUGIN_VAR_STR: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1295 |
src= &((sessionvar_str_t*) plugin_var)->def_val; |
1
by brian
clean slate |
1296 |
break; |
1297 |
default: |
|
51.1.62
by Jay Pipes
Removed/replaced BUG symbols and standardized TRUE/FALSE |
1298 |
assert(0); |
1
by brian
clean slate |
1299 |
}
|
1300 |
}
|
|
1301 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1302 |
/* session must equal current_session if PLUGIN_VAR_SessionLOCAL flag is set */
|
520.1.21
by Brian Aker
THD -> Session rename |
1303 |
assert(!(plugin_var->flags & PLUGIN_VAR_SessionLOCAL) || |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1304 |
session == current_session); |
1
by brian
clean slate |
1305 |
|
520.1.21
by Brian Aker
THD -> Session rename |
1306 |
if (!(plugin_var->flags & PLUGIN_VAR_SessionLOCAL) || type == OPT_GLOBAL) |
1
by brian
clean slate |
1307 |
{
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1308 |
plugin_var->update(session, plugin_var, tgt, src); |
1
by brian
clean slate |
1309 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
1310 |
}
|
|
1311 |
else
|
|
1312 |
{
|
|
1313 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1314 |
plugin_var->update(session, plugin_var, tgt, src); |
1
by brian
clean slate |
1315 |
}
|
1316 |
}
|
|
1317 |
||
1318 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
1319 |
bool sys_var_pluginvar::update(Session *session, set_var *var) |
1
by brian
clean slate |
1320 |
{
|
1321 |
void *tgt; |
|
1322 |
||
51.1.62
by Jay Pipes
Removed/replaced BUG symbols and standardized TRUE/FALSE |
1323 |
assert(is_readonly() || plugin_var->update); |
1
by brian
clean slate |
1324 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1325 |
/* session must equal current_session if PLUGIN_VAR_SessionLOCAL flag is set */
|
520.1.21
by Brian Aker
THD -> Session rename |
1326 |
assert(!(plugin_var->flags & PLUGIN_VAR_SessionLOCAL) || |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1327 |
session == current_session); |
1
by brian
clean slate |
1328 |
|
1329 |
if (is_readonly()) |
|
1330 |
return 1; |
|
1331 |
||
1332 |
pthread_mutex_lock(&LOCK_global_system_variables); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1333 |
tgt= real_value_ptr(session, var->type); |
1
by brian
clean slate |
1334 |
|
520.1.21
by Brian Aker
THD -> Session rename |
1335 |
if (!(plugin_var->flags & PLUGIN_VAR_SessionLOCAL) || var->type == OPT_GLOBAL) |
1
by brian
clean slate |
1336 |
{
|
1337 |
/* variable we are updating has global scope, so we unlock after updating */
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1338 |
plugin_var->update(session, plugin_var, tgt, &var->save_result); |
1
by brian
clean slate |
1339 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
1340 |
}
|
|
1341 |
else
|
|
1342 |
{
|
|
1343 |
pthread_mutex_unlock(&LOCK_global_system_variables); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1344 |
plugin_var->update(session, plugin_var, tgt, &var->save_result); |
1
by brian
clean slate |
1345 |
}
|
1346 |
return 0; |
|
1347 |
}
|
|
1348 |
||
1349 |
||
1350 |
#define OPTION_SET_LIMITS(type, options, opt) \
|
|
322.2.2
by Mats Kindahl
Hiding THD::proc_info field and providing a setter and getter. |
1351 |
options->var_type= type; \
|
1352 |
options->def_value= (opt)->def_val; \
|
|
1353 |
options->min_value= (opt)->min_val; \
|
|
1354 |
options->max_value= (opt)->max_val; \
|
|
1
by brian
clean slate |
1355 |
options->block_size= (long) (opt)->blk_sz
|
1356 |
||
1357 |
||
1410.3.4
by Djellel E. Difallah
update references to old my_'s |
1358 |
void plugin_opt_set_limits(struct option *options, |
1251.2.2
by Jay Pipes
Pulls MyISAM-specific server variables into the MyISAM |
1359 |
const drizzle_sys_var *opt) |
1
by brian
clean slate |
1360 |
{
|
1361 |
options->sub_size= 0; |
|
1362 |
||
1363 |
switch (opt->flags & (PLUGIN_VAR_TYPEMASK | |
|
520.1.21
by Brian Aker
THD -> Session rename |
1364 |
PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_SessionLOCAL)) { |
1
by brian
clean slate |
1365 |
/* global system variables */
|
1366 |
case PLUGIN_VAR_INT: |
|
1367 |
OPTION_SET_LIMITS(GET_INT, options, (sysvar_int_t*) opt); |
|
1368 |
break; |
|
1369 |
case PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED: |
|
1370 |
OPTION_SET_LIMITS(GET_UINT, options, (sysvar_uint_t*) opt); |
|
1371 |
break; |
|
1372 |
case PLUGIN_VAR_LONG: |
|
1373 |
OPTION_SET_LIMITS(GET_LONG, options, (sysvar_long_t*) opt); |
|
1374 |
break; |
|
1375 |
case PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED: |
|
896.4.16
by Stewart Smith
for getopt, replace GET_ULONG with GET_UINT32. |
1376 |
OPTION_SET_LIMITS(GET_ULONG_IS_FAIL, options, (sysvar_ulong_t*) opt); |
1
by brian
clean slate |
1377 |
break; |
1378 |
case PLUGIN_VAR_LONGLONG: |
|
152
by Brian Aker
longlong replacement |
1379 |
OPTION_SET_LIMITS(GET_LL, options, (sysvar_int64_t_t*) opt); |
1
by brian
clean slate |
1380 |
break; |
1381 |
case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED: |
|
151
by Brian Aker
Ulonglong to uint64_t |
1382 |
OPTION_SET_LIMITS(GET_ULL, options, (sysvar_uint64_t_t*) opt); |
1
by brian
clean slate |
1383 |
break; |
1384 |
case PLUGIN_VAR_BOOL: |
|
1385 |
options->var_type= GET_BOOL; |
|
1386 |
options->def_value= ((sysvar_bool_t*) opt)->def_val; |
|
1387 |
break; |
|
1388 |
case PLUGIN_VAR_STR: |
|
1389 |
options->var_type= ((opt->flags & PLUGIN_VAR_MEMALLOC) ? |
|
1390 |
GET_STR_ALLOC : GET_STR); |
|
157
by Brian Aker
Second pass cleanup on removal of my_uint types |
1391 |
options->def_value= (intptr_t) ((sysvar_str_t*) opt)->def_val; |
1
by brian
clean slate |
1392 |
break; |
1393 |
/* threadlocal variables */
|
|
520.1.21
by Brian Aker
THD -> Session rename |
1394 |
case PLUGIN_VAR_INT | PLUGIN_VAR_SessionLOCAL: |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1395 |
OPTION_SET_LIMITS(GET_INT, options, (sessionvar_int_t*) opt); |
1
by brian
clean slate |
1396 |
break; |
520.1.21
by Brian Aker
THD -> Session rename |
1397 |
case PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_SessionLOCAL: |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1398 |
OPTION_SET_LIMITS(GET_UINT, options, (sessionvar_uint_t*) opt); |
1
by brian
clean slate |
1399 |
break; |
520.1.21
by Brian Aker
THD -> Session rename |
1400 |
case PLUGIN_VAR_LONG | PLUGIN_VAR_SessionLOCAL: |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1401 |
OPTION_SET_LIMITS(GET_LONG, options, (sessionvar_long_t*) opt); |
1
by brian
clean slate |
1402 |
break; |
520.1.21
by Brian Aker
THD -> Session rename |
1403 |
case PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_SessionLOCAL: |
896.4.16
by Stewart Smith
for getopt, replace GET_ULONG with GET_UINT32. |
1404 |
OPTION_SET_LIMITS(GET_ULONG_IS_FAIL, options, (sessionvar_ulong_t*) opt); |
1
by brian
clean slate |
1405 |
break; |
520.1.21
by Brian Aker
THD -> Session rename |
1406 |
case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_SessionLOCAL: |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1407 |
OPTION_SET_LIMITS(GET_LL, options, (sessionvar_int64_t_t*) opt); |
1
by brian
clean slate |
1408 |
break; |
520.1.21
by Brian Aker
THD -> Session rename |
1409 |
case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | PLUGIN_VAR_SessionLOCAL: |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1410 |
OPTION_SET_LIMITS(GET_ULL, options, (sessionvar_uint64_t_t*) opt); |
1
by brian
clean slate |
1411 |
break; |
520.1.21
by Brian Aker
THD -> Session rename |
1412 |
case PLUGIN_VAR_BOOL | PLUGIN_VAR_SessionLOCAL: |
1
by brian
clean slate |
1413 |
options->var_type= GET_BOOL; |
520.1.22
by Brian Aker
Second pass of thd cleanup |
1414 |
options->def_value= ((sessionvar_bool_t*) opt)->def_val; |
1
by brian
clean slate |
1415 |
break; |
520.1.21
by Brian Aker
THD -> Session rename |
1416 |
case PLUGIN_VAR_STR | PLUGIN_VAR_SessionLOCAL: |
1
by brian
clean slate |
1417 |
options->var_type= ((opt->flags & PLUGIN_VAR_MEMALLOC) ? |
1418 |
GET_STR_ALLOC : GET_STR); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1419 |
options->def_value= (intptr_t) ((sessionvar_str_t*) opt)->def_val; |
1
by brian
clean slate |
1420 |
break; |
1421 |
default: |
|
51.1.62
by Jay Pipes
Removed/replaced BUG symbols and standardized TRUE/FALSE |
1422 |
assert(0); |
1
by brian
clean slate |
1423 |
}
|
1424 |
options->arg_type= REQUIRED_ARG; |
|
1425 |
if (opt->flags & PLUGIN_VAR_NOCMDARG) |
|
1426 |
options->arg_type= NO_ARG; |
|
1427 |
if (opt->flags & PLUGIN_VAR_OPCMDARG) |
|
1428 |
options->arg_type= OPT_ARG; |
|
1429 |
}
|
|
1430 |
||
1410.3.4
by Djellel E. Difallah
update references to old my_'s |
1431 |
static int get_one_plugin_option(int, const struct option *, char *) |
1
by brian
clean slate |
1432 |
{
|
1433 |
return 0; |
|
1434 |
}
|
|
1435 |
||
1436 |
||
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
1437 |
static int construct_options(memory::Root *mem_root, module::Module *tmp, |
1410.3.4
by Djellel E. Difallah
update references to old my_'s |
1438 |
option *options) |
1
by brian
clean slate |
1439 |
{
|
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
1440 |
|
1441 |
int localoptionid= 256; |
|
1442 |
const string plugin_name(tmp->getManifest().name); |
|
1443 |
||
1444 |
size_t namelen= plugin_name.size(), optnamelen; |
|
1445 |
||
1
by brian
clean slate |
1446 |
char *optname, *p; |
1447 |
int index= 0, offset= 0; |
|
1228.1.5
by Monty Taylor
Merged in some naming things. |
1448 |
drizzle_sys_var *opt, **plugin_option; |
1
by brian
clean slate |
1449 |
st_bookmark *v; |
1450 |
||
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
1451 |
string name(plugin_name); |
1452 |
transform(name.begin(), name.end(), name.begin(), ::tolower); |
|
1453 |
||
1454 |
for (string::iterator iter= name.begin(); iter != name.end(); ++iter) |
|
1455 |
{
|
|
1456 |
if (*iter == '_') |
|
1457 |
*iter= '-'; |
|
1458 |
}
|
|
1
by brian
clean slate |
1459 |
|
1460 |
/*
|
|
1461 |
Two passes as the 2nd pass will take pointer addresses for use
|
|
1462 |
by my_getopt and register_var() in the first pass uses realloc
|
|
1463 |
*/
|
|
1464 |
||
1093.3.4
by Monty Taylor
Naming cleanups. |
1465 |
for (plugin_option= tmp->getManifest().system_vars; |
1
by brian
clean slate |
1466 |
plugin_option && *plugin_option; plugin_option++, index++) |
1467 |
{
|
|
1468 |
opt= *plugin_option; |
|
520.1.21
by Brian Aker
THD -> Session rename |
1469 |
if (!(opt->flags & PLUGIN_VAR_SessionLOCAL)) |
1
by brian
clean slate |
1470 |
continue; |
1471 |
if (!(register_var(name, opt->name, opt->flags))) |
|
1472 |
continue; |
|
1473 |
switch (opt->flags & PLUGIN_VAR_TYPEMASK) { |
|
1474 |
case PLUGIN_VAR_BOOL: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1475 |
(((sessionvar_bool_t *)opt)->resolve)= mysql_sys_var_ptr_bool; |
1
by brian
clean slate |
1476 |
break; |
1477 |
case PLUGIN_VAR_INT: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1478 |
(((sessionvar_int_t *)opt)->resolve)= mysql_sys_var_ptr_int; |
1
by brian
clean slate |
1479 |
break; |
1480 |
case PLUGIN_VAR_LONG: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1481 |
(((sessionvar_long_t *)opt)->resolve)= mysql_sys_var_ptr_long; |
1
by brian
clean slate |
1482 |
break; |
1483 |
case PLUGIN_VAR_LONGLONG: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1484 |
(((sessionvar_int64_t_t *)opt)->resolve)= mysql_sys_var_ptr_int64_t; |
1
by brian
clean slate |
1485 |
break; |
1486 |
case PLUGIN_VAR_STR: |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
1487 |
(((sessionvar_str_t *)opt)->resolve)= mysql_sys_var_ptr_str; |
1
by brian
clean slate |
1488 |
break; |
1489 |
default: |
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
1490 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown variable type code 0x%x in plugin '%s'."), |
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
1491 |
opt->flags, plugin_name.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 |
1492 |
return(-1); |
1
by brian
clean slate |
1493 |
};
|
1494 |
}
|
|
1495 |
||
1093.3.4
by Monty Taylor
Naming cleanups. |
1496 |
for (plugin_option= tmp->getManifest().system_vars; |
1
by brian
clean slate |
1497 |
plugin_option && *plugin_option; plugin_option++, index++) |
1498 |
{
|
|
1499 |
switch ((opt= *plugin_option)->flags & PLUGIN_VAR_TYPEMASK) { |
|
1500 |
case PLUGIN_VAR_BOOL: |
|
1501 |
if (!opt->check) |
|
1502 |
opt->check= check_func_bool; |
|
1503 |
if (!opt->update) |
|
1504 |
opt->update= update_func_bool; |
|
1505 |
break; |
|
1506 |
case PLUGIN_VAR_INT: |
|
1507 |
if (!opt->check) |
|
1508 |
opt->check= check_func_int; |
|
1509 |
if (!opt->update) |
|
1510 |
opt->update= update_func_int; |
|
1511 |
break; |
|
1512 |
case PLUGIN_VAR_LONG: |
|
1513 |
if (!opt->check) |
|
1514 |
opt->check= check_func_long; |
|
1515 |
if (!opt->update) |
|
1516 |
opt->update= update_func_long; |
|
1517 |
break; |
|
1518 |
case PLUGIN_VAR_LONGLONG: |
|
1519 |
if (!opt->check) |
|
152
by Brian Aker
longlong replacement |
1520 |
opt->check= check_func_int64_t; |
1
by brian
clean slate |
1521 |
if (!opt->update) |
152
by Brian Aker
longlong replacement |
1522 |
opt->update= update_func_int64_t; |
1
by brian
clean slate |
1523 |
break; |
1524 |
case PLUGIN_VAR_STR: |
|
1525 |
if (!opt->check) |
|
1526 |
opt->check= check_func_str; |
|
1527 |
if (!opt->update) |
|
1528 |
{
|
|
1529 |
opt->update= update_func_str; |
|
9
by Brian Aker
Warnings cleanup |
1530 |
if ((opt->flags & (PLUGIN_VAR_MEMALLOC | PLUGIN_VAR_READONLY)) == false) |
1
by brian
clean slate |
1531 |
{
|
1532 |
opt->flags|= PLUGIN_VAR_READONLY; |
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
1533 |
errmsg_printf(ERRMSG_LVL_WARN, _("Server variable %s of plugin %s was forced " |
1
by brian
clean slate |
1534 |
"to be read-only: string variable without "
|
338
by Monty Taylor
Tagged more strings. |
1535 |
"update_func and PLUGIN_VAR_MEMALLOC flag"), |
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
1536 |
opt->name, plugin_name.c_str()); |
1
by brian
clean slate |
1537 |
}
|
1538 |
}
|
|
1539 |
break; |
|
1540 |
default: |
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
1541 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Unknown variable type code 0x%x in plugin '%s'."), |
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
1542 |
opt->flags, plugin_name.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 |
1543 |
return(-1); |
1
by brian
clean slate |
1544 |
}
|
1545 |
||
520.1.21
by Brian Aker
THD -> Session rename |
1546 |
if ((opt->flags & (PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_SessionLOCAL)) |
1
by brian
clean slate |
1547 |
== PLUGIN_VAR_NOCMDOPT) |
1548 |
continue; |
|
1549 |
||
1550 |
if (!opt->name) |
|
1551 |
{
|
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
1552 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Missing variable name in plugin '%s'."), |
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
1553 |
plugin_name.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 |
1554 |
return(-1); |
1
by brian
clean slate |
1555 |
}
|
1556 |
||
520.1.21
by Brian Aker
THD -> Session rename |
1557 |
if (!(opt->flags & PLUGIN_VAR_SessionLOCAL)) |
1
by brian
clean slate |
1558 |
{
|
1559 |
optnamelen= strlen(opt->name); |
|
1485
by Brian Aker
Updates to confine memroot |
1560 |
optname= (char*) mem_root->alloc_root(namelen + optnamelen + 2); |
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
1561 |
sprintf(optname, "%s-%s", name.c_str(), opt->name); |
1
by brian
clean slate |
1562 |
optnamelen= namelen + optnamelen + 1; |
1563 |
}
|
|
1564 |
else
|
|
1565 |
{
|
|
1566 |
/* this should not fail because register_var should create entry */
|
|
1567 |
if (!(v= find_bookmark(name, opt->name, opt->flags))) |
|
1568 |
{
|
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
1569 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Thread local variable '%s' not allocated " |
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
1570 |
"in plugin '%s'."), opt->name, plugin_name.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 |
1571 |
return(-1); |
1
by brian
clean slate |
1572 |
}
|
1573 |
||
1574 |
*(int*)(opt + 1)= offset= v->offset; |
|
1575 |
||
1576 |
if (opt->flags & PLUGIN_VAR_NOCMDOPT) |
|
1577 |
continue; |
|
1578 |
||
1487
by Brian Aker
More updates for memory::Root |
1579 |
optname= (char*) mem_root->memdup_root(v->key + 1, (optnamelen= v->name_len) + 1); |
1
by brian
clean slate |
1580 |
}
|
1581 |
||
1582 |
/* convert '_' to '-' */
|
|
1583 |
for (p= optname; *p; p++) |
|
1584 |
if (*p == '_') |
|
1585 |
*p= '-'; |
|
1586 |
||
1587 |
options->name= optname; |
|
1588 |
options->comment= opt->comment; |
|
1589 |
options->app_type= opt; |
|
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
1590 |
options->id= localoptionid++; |
1
by brian
clean slate |
1591 |
|
1592 |
plugin_opt_set_limits(options, opt); |
|
1593 |
||
520.1.21
by Brian Aker
THD -> Session rename |
1594 |
if (opt->flags & PLUGIN_VAR_SessionLOCAL) |
77.1.78
by Monty Taylor
One last bunch of warnings edits. |
1595 |
options->value= options->u_max_value= (char**) |
1
by brian
clean slate |
1596 |
(global_system_variables.dynamic_variables_ptr + offset); |
1597 |
else
|
|
77.1.78
by Monty Taylor
One last bunch of warnings edits. |
1598 |
options->value= options->u_max_value= *(char***) (opt + 1); |
1
by brian
clean slate |
1599 |
|
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
1600 |
options++; |
1
by brian
clean slate |
1601 |
}
|
1602 |
||
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 |
1603 |
return(0); |
1
by brian
clean slate |
1604 |
}
|
1605 |
||
1606 |
||
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
1607 |
static option *construct_help_options(memory::Root *mem_root, module::Module *p) |
1
by brian
clean slate |
1608 |
{
|
1228.1.5
by Monty Taylor
Merged in some naming things. |
1609 |
drizzle_sys_var **opt; |
1410.3.4
by Djellel E. Difallah
update references to old my_'s |
1610 |
option *opts; |
482
by Brian Aker
Remove uint. |
1611 |
uint32_t count= EXTRA_OPTIONS; |
1
by brian
clean slate |
1612 |
|
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
1613 |
for (opt= p->getManifest().system_vars; opt && *opt; opt++, count++) {}; |
1
by brian
clean slate |
1614 |
|
1485
by Brian Aker
Updates to confine memroot |
1615 |
opts= (option*)mem_root->alloc_root((sizeof(option) * count)); |
1093.3.5
by Monty Taylor
Removed a dynamic array. |
1616 |
if (opts == NULL) |
1019.1.6
by Brian Aker
A number of random cleanups. |
1617 |
return NULL; |
1
by brian
clean slate |
1618 |
|
1410.3.4
by Djellel E. Difallah
update references to old my_'s |
1619 |
memset(opts, 0, sizeof(option) * count); |
1
by brian
clean slate |
1620 |
|
1241.10.5
by Monty Taylor
Removed hardcoded option options around myisam and memory. |
1621 |
if (construct_options(mem_root, p, opts)) |
1019.1.6
by Brian Aker
A number of random cleanups. |
1622 |
return NULL; |
1
by brian
clean slate |
1623 |
|
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 |
1624 |
return(opts); |
1
by brian
clean slate |
1625 |
}
|
1626 |
||
1101.1.27
by Monty Taylor
Fixed the plugin string valgrind leak. |
1627 |
void drizzle_add_plugin_sysvar(sys_var_pluginvar *var) |
1628 |
{
|
|
1629 |
plugin_sysvar_vec.push_back(var); |
|
1630 |
}
|
|
1631 |
||
1632 |
void drizzle_del_plugin_sysvar() |
|
1633 |
{
|
|
1634 |
vector<sys_var_pluginvar *>::iterator iter= plugin_sysvar_vec.begin(); |
|
1635 |
while(iter != plugin_sysvar_vec.end()) |
|
1636 |
{
|
|
1637 |
delete *iter; |
|
1638 |
++iter; |
|
1639 |
}
|
|
1640 |
plugin_sysvar_vec.clear(); |
|
1641 |
}
|
|
1
by brian
clean slate |
1642 |
|
1643 |
/*
|
|
1644 |
SYNOPSIS
|
|
1645 |
test_plugin_options()
|
|
1646 |
tmp_root temporary scratch space
|
|
1647 |
plugin internal plugin structure
|
|
1648 |
argc user supplied arguments
|
|
1649 |
argv user supplied arguments
|
|
1650 |
default_enabled default plugin enable status
|
|
1651 |
RETURNS:
|
|
1652 |
0 SUCCESS - plugin should be enabled/loaded
|
|
1653 |
NOTE:
|
|
1654 |
Requires that a write-lock is held on LOCK_system_variables_hash
|
|
1655 |
*/
|
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
1656 |
static int test_plugin_options(memory::Root *tmp_root, module::Module *tmp, |
135
by Brian Aker
Random cleanup. Dead partition tests, pass operator in sql_plugin, mtr based |
1657 |
int *argc, char **argv) |
1
by brian
clean slate |
1658 |
{
|
1659 |
struct sys_var_chain chain= { NULL, NULL }; |
|
1228.1.5
by Monty Taylor
Merged in some naming things. |
1660 |
drizzle_sys_var **opt; |
1410.3.4
by Djellel E. Difallah
update references to old my_'s |
1661 |
option *opts= NULL; |
1
by brian
clean slate |
1662 |
int error; |
1228.1.5
by Monty Taylor
Merged in some naming things. |
1663 |
drizzle_sys_var *o; |
1
by brian
clean slate |
1664 |
struct st_bookmark *var; |
482
by Brian Aker
Remove uint. |
1665 |
uint32_t len, count= EXTRA_OPTIONS; |
1
by brian
clean slate |
1666 |
|
1093.3.4
by Monty Taylor
Naming cleanups. |
1667 |
for (opt= tmp->getManifest().system_vars; opt && *opt; opt++) |
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
1668 |
count++; |
1
by brian
clean slate |
1669 |
|
1670 |
||
1671 |
if (count > EXTRA_OPTIONS || (*argc > 1)) |
|
1672 |
{
|
|
1485
by Brian Aker
Updates to confine memroot |
1673 |
if (!(opts= (option*) tmp_root->alloc_root(sizeof(option) * count))) |
1
by brian
clean slate |
1674 |
{
|
1093.3.4
by Monty Taylor
Naming cleanups. |
1675 |
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 |
1676 |
return(-1); |
1
by brian
clean slate |
1677 |
}
|
1410.3.4
by Djellel E. Difallah
update references to old my_'s |
1678 |
memset(opts, 0, sizeof(option) * count); |
1
by brian
clean slate |
1679 |
|
1241.10.5
by Monty Taylor
Removed hardcoded option options around myisam and memory. |
1680 |
if (construct_options(tmp_root, tmp, opts)) |
1
by brian
clean slate |
1681 |
{
|
1093.3.4
by Monty Taylor
Naming cleanups. |
1682 |
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 |
1683 |
return(-1); |
1
by brian
clean slate |
1684 |
}
|
1685 |
||
1686 |
error= handle_options(argc, &argv, opts, get_one_plugin_option); |
|
1687 |
(*argc)++; /* add back one for the program name */ |
|
1688 |
||
1689 |
if (error) |
|
1690 |
{
|
|
755.2.1
by Mark Atwood
replace sql_print_error etc with errmsg_print |
1691 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Parsing options for plugin '%s' failed."), |
1093.3.4
by Monty Taylor
Naming cleanups. |
1692 |
tmp->getName().c_str()); |
1
by brian
clean slate |
1693 |
goto err; |
1694 |
}
|
|
1695 |
}
|
|
1696 |
||
1697 |
error= 1; |
|
1698 |
||
779.3.53
by Monty Taylor
Revert the fail. |
1699 |
{
|
1093.3.4
by Monty Taylor
Naming cleanups. |
1700 |
for (opt= tmp->getManifest().system_vars; opt && *opt; opt++) |
779.3.53
by Monty Taylor
Revert the fail. |
1701 |
{
|
1106.1.2
by Brian Aker
Additional fixes from Monty |
1702 |
sys_var *v; |
779.3.53
by Monty Taylor
Revert the fail. |
1703 |
if (((o= *opt)->flags & PLUGIN_VAR_NOSYSVAR)) |
1704 |
continue; |
|
1705 |
||
1283.1.1
by Monty Taylor
Remove code which adds skip options for plugins, since that's not how we |
1706 |
if ((var= find_bookmark(tmp->getName(), o->name, o->flags))) |
1101.1.27
by Monty Taylor
Fixed the plugin string valgrind leak. |
1707 |
v= new sys_var_pluginvar(var->key + 1, o); |
779.3.53
by Monty Taylor
Revert the fail. |
1708 |
else
|
1709 |
{
|
|
1093.3.4
by Monty Taylor
Naming cleanups. |
1710 |
len= tmp->getName().length() + strlen(o->name) + 2; |
1101.1.27
by Monty Taylor
Fixed the plugin string valgrind leak. |
1711 |
string vname(tmp->getName()); |
1712 |
vname.push_back('-'); |
|
1713 |
vname.append(o->name); |
|
1714 |
transform(vname.begin(), vname.end(), vname.begin(), ::tolower); |
|
1715 |
string::iterator p= vname.begin(); |
|
1716 |
while (p != vname.end()) |
|
1717 |
{
|
|
779.3.53
by Monty Taylor
Revert the fail. |
1718 |
if (*p == '-') |
1719 |
*p= '_'; |
|
1101.1.27
by Monty Taylor
Fixed the plugin string valgrind leak. |
1720 |
++p; |
1721 |
}
|
|
779.3.53
by Monty Taylor
Revert the fail. |
1722 |
|
1101.1.27
by Monty Taylor
Fixed the plugin string valgrind leak. |
1723 |
v= new sys_var_pluginvar(vname, o); |
779.3.53
by Monty Taylor
Revert the fail. |
1724 |
}
|
1725 |
assert(v); /* check that an object was actually constructed */ |
|
1726 |
||
1101.1.27
by Monty Taylor
Fixed the plugin string valgrind leak. |
1727 |
drizzle_add_plugin_sysvar(static_cast<sys_var_pluginvar *>(v)); |
779.3.53
by Monty Taylor
Revert the fail. |
1728 |
/*
|
1729 |
Add to the chain of variables.
|
|
1730 |
Done like this for easier debugging so that the
|
|
1731 |
pointer to v is not lost on optimized builds.
|
|
1732 |
*/
|
|
1733 |
v->chain_sys_var(&chain); |
|
1734 |
}
|
|
1735 |
if (chain.first) |
|
1736 |
{
|
|
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. |
1737 |
chain.last->setNext(NULL); |
779.3.53
by Monty Taylor
Revert the fail. |
1738 |
if (mysql_add_sys_var_chain(chain.first, NULL)) |
1739 |
{
|
|
1740 |
errmsg_printf(ERRMSG_LVL_ERROR, _("Plugin '%s' has conflicting system variables"), |
|
1093.3.4
by Monty Taylor
Naming cleanups. |
1741 |
tmp->getName().c_str()); |
779.3.53
by Monty Taylor
Revert the fail. |
1742 |
goto err; |
1743 |
}
|
|
1744 |
tmp->system_vars= chain.first; |
|
1745 |
}
|
|
1746 |
return(0); |
|
1747 |
}
|
|
1748 |
||
1
by brian
clean slate |
1749 |
err: |
1750 |
if (opts) |
|
1751 |
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 |
1752 |
return(error); |
1
by brian
clean slate |
1753 |
}
|
1754 |
||
1755 |
||
1756 |
/****************************************************************************
|
|
1757 |
Help Verbose text with Plugin System Variables
|
|
1758 |
****************************************************************************/
|
|
1759 |
||
1093.3.5
by Monty Taylor
Removed a dynamic array. |
1760 |
class OptionCmp |
1761 |
{
|
|
1762 |
public: |
|
1410.3.4
by Djellel E. Difallah
update references to old my_'s |
1763 |
bool operator() (const option &a, const option &b) |
1093.3.5
by Monty Taylor
Removed a dynamic array. |
1764 |
{
|
1765 |
return my_strcasecmp(&my_charset_utf8_general_ci, a.name, b.name); |
|
1766 |
}
|
|
1767 |
};
|
|
1768 |
||
1769 |
||
1410.3.4
by Djellel E. Difallah
update references to old my_'s |
1770 |
void my_print_help_inc_plugins(option *main_options) |
1093.3.5
by Monty Taylor
Removed a dynamic array. |
1771 |
{
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
1772 |
module::Registry ®istry= module::Registry::singleton(); |
1410.3.4
by Djellel E. Difallah
update references to old my_'s |
1773 |
vector<option> all_options; |
1485
by Brian Aker
Updates to confine memroot |
1774 |
memory::Root mem_root(4096); |
1410.3.4
by Djellel E. Difallah
update references to old my_'s |
1775 |
option *opt= NULL; |
1
by brian
clean slate |
1776 |
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
1777 |
|
1
by brian
clean slate |
1778 |
if (initialized) |
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
1779 |
{
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
1780 |
std::map<std::string, module::Module *>::const_iterator modules= |
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
1781 |
registry.getModulesMap().begin(); |
1782 |
||
1783 |
while (modules != registry.getModulesMap().end()) |
|
1
by brian
clean slate |
1784 |
{
|
1530.2.5
by Monty Taylor
Renamed classes that were in drizzled::plugin but which were not meant |
1785 |
module::Module *p= (*modules).second; |
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
1786 |
++modules; |
1
by brian
clean slate |
1787 |
|
1093.3.5
by Monty Taylor
Removed a dynamic array. |
1788 |
if (p->getManifest().system_vars == NULL) |
1789 |
continue; |
|
1790 |
||
1791 |
opt= construct_help_options(&mem_root, p); |
|
1792 |
if (opt == NULL) |
|
1
by brian
clean slate |
1793 |
continue; |
1794 |
||
1795 |
/* Only options with a non-NULL comment are displayed in help text */
|
|
1796 |
for (;opt->id; opt++) |
|
1093.3.5
by Monty Taylor
Removed a dynamic array. |
1797 |
{
|
1
by brian
clean slate |
1798 |
if (opt->comment) |
1093.3.5
by Monty Taylor
Removed a dynamic array. |
1799 |
{
|
1800 |
all_options.push_back(*opt); |
|
1801 |
||
1802 |
}
|
|
1803 |
}
|
|
1
by brian
clean slate |
1804 |
}
|
1228.1.3
by Monty Taylor
All of the outstanding plugin loader system cleanups: |
1805 |
}
|
1
by brian
clean slate |
1806 |
|
1807 |
for (;main_options->id; main_options++) |
|
1093.3.5
by Monty Taylor
Removed a dynamic array. |
1808 |
{
|
1809 |
if (main_options->comment) |
|
1810 |
{
|
|
1811 |
all_options.push_back(*main_options); |
|
1812 |
}
|
|
1813 |
}
|
|
1
by brian
clean slate |
1814 |
|
1093.3.5
by Monty Taylor
Removed a dynamic array. |
1815 |
/**
|
1410.3.4
by Djellel E. Difallah
update references to old my_'s |
1816 |
* @TODO: Fix the option building so that it doens't break sort
|
1093.3.5
by Monty Taylor
Removed a dynamic array. |
1817 |
*
|
1818 |
* sort(all_options.begin(), all_options.end(), OptionCmp());
|
|
1819 |
*/
|
|
1
by brian
clean slate |
1820 |
|
1821 |
/* main_options now points to the empty option terminator */
|
|
1093.3.5
by Monty Taylor
Removed a dynamic array. |
1822 |
all_options.push_back(*main_options); |
1823 |
||
1824 |
my_print_help(&*(all_options.begin())); |
|
1825 |
my_print_variables(&*(all_options.begin())); |
|
1826 |
||
1487
by Brian Aker
More updates for memory::Root |
1827 |
mem_root.free_root(MYF(0)); |
1
by brian
clean slate |
1828 |
}
|
1829 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
1830 |
} /* namespace drizzled */ |
1530.2.3
by Monty Taylor
Changed the builtin plugin code path to work exactly the same as dynamic. |
1831 |
|
1832 |