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