Merge lp:~jaypipes/drizzle/captain into lp:~drizzle-trunk/drizzle/development

Proposed by Jay Pipes
Status: Merged
Merged at revision: not available
Proposed branch: lp:~jaypipes/drizzle/captain
Merge into: lp:~drizzle-trunk/drizzle/development
Diff against target: None lines
To merge this branch: bzr merge lp:~jaypipes/drizzle/captain

This proposal supersedes a proposal from 2009-07-18.

To post a comment you must log in.
Revision history for this message
Jay Pipes (jaypipes) wrote : Posted in a previous version of this proposal

Contains Monty's build-cleanup and plugin class cleanup branches. All tests pass on Linux64, Solaris64, and MacOSX64, with only known exception of drizzledump failure on Solaris and myisamcheck failure on MacOSX.

Revision history for this message
Jay Pipes (jaypipes) wrote :

Contains Monty's build-cleanup and plugin class cleanup branches. All tests pass on Linux64, Solaris64, and MacOSX64, with only known exception of drizzledump failure on Solaris and myisamcheck failure on MacOSX. Also includes Pandora build fixes for Solaris.

lp:~jaypipes/drizzle/captain updated
1098. By Brian Aker <brian@gaz>

Merge Jay

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile.am'
--- Makefile.am 2009-07-11 19:23:04 +0000
+++ Makefile.am 2009-07-17 23:20:36 +0000
@@ -128,7 +128,6 @@
128 mysys/charset.cc \128 mysys/charset.cc \
129 mysys/checksum.cc \129 mysys/checksum.cc \
130 mysys/default.cc \130 mysys/default.cc \
131 mysys/default_modify.cc \
132 mysys/dynamic_array.cc \131 mysys/dynamic_array.cc \
133 mysys/errors.cc \132 mysys/errors.cc \
134 mysys/hash.cc \133 mysys/hash.cc \
135134
=== modified file 'client/drizzle.1'
--- client/drizzle.1 2009-05-23 23:51:18 +0000
+++ client/drizzle.1 2009-07-17 17:13:52 +0000
@@ -1018,7 +1018,7 @@
1018The1018The
1019\fBprompt\fR1019\fBprompt\fR
1020command reconfigures the default1020command reconfigures the default
1021mysql>1021drizzle>
1022prompt. The string for defining the prompt can contain the following special sequences.1022prompt. The string for defining the prompt can contain the following special sequences.
1023.TS1023.TS
1024allbox tab(:);1024allbox tab(:);
@@ -1100,7 +1100,7 @@
1100\\U1100\\U
1101T}:T{1101T}:T{
1102Your full1102Your full
1103 \fIuser_name\fR@\fIhost_name\fR1103 \fIuser\fR@\fIhost\fR
1104 account name1104 account name
1105T}1105T}
1106T{1106T{
11071107
=== modified file 'client/drizzledump.1'
--- client/drizzledump.1 2009-05-23 23:51:18 +0000
+++ client/drizzledump.1 2009-07-17 17:13:52 +0000
@@ -989,19 +989,20 @@
989NULL (\fIunknown value\fR)989NULL (\fIunknown value\fR)
990T}:T{990T}:T{
991<field name="\fIcolumn_name\fR"991<field name="\fIcolumn_name\fR"
992 xsi:nil="true" />992 xsi:nil="true" />
993T}993T}
994T{994T{
995\'' (\fIempty string\fR)995\'' (\fIempty string\fR)
996T}:T{996T}:T{
997<field997<field name="\fIcolumn_name\fR">
998 name="\fIcolumn_name\fR"></field>998</field>
999T}999T}
1000T{1000T{
1001\'NULL' (\fIstring value\fR)1001\'NULL' (\fIstring value\fR)
1002T}:T{1002T}:T{
1003<field1003<field name="\fIcolumn_name\fR">
1004 name="\fIcolumn_name\fR">NULL</field>1004NULL
1005</field>
1005T}1006T}
1006.TE1007.TE
1007.sp1008.sp
10081009
=== modified file 'config/uncrustify.cfg'
--- config/uncrustify.cfg 2009-07-10 21:50:02 +0000
+++ config/uncrustify.cfg 2009-07-15 21:16:34 +0000
@@ -60,8 +60,8 @@
60nl_create_if_one_liner=false60nl_create_if_one_liner=false
61nl_create_for_one_liner=false61nl_create_for_one_liner=false
62nl_create_while_one_liner=false62nl_create_while_one_liner=false
63ls_for_split_full=true63ls_for_split_full=false
64ls_func_split_full=true64ls_func_split_full=false
65nl_after_multiline_comment=true65nl_after_multiline_comment=true
66eat_blanks_after_open_brace=true66eat_blanks_after_open_brace=true
67eat_blanks_before_close_brace=true67eat_blanks_before_close_brace=true
6868
=== modified file 'drizzled/Makefile.am'
--- drizzled/Makefile.am 2009-07-12 18:36:46 +0000
+++ drizzled/Makefile.am 2009-07-15 21:47:32 +0000
@@ -267,8 +267,11 @@
267 plugin/applier.h \267 plugin/applier.h \
268 plugin/authentication.h \268 plugin/authentication.h \
269 plugin/error_message_handler.h \269 plugin/error_message_handler.h \
270 plugin/handle.h \
271 plugin/library.h \
270 plugin/listen.h \272 plugin/listen.h \
271 plugin/logging_handler.h \273 plugin/logging_handler.h \
274 plugin/manifest.h \
272 plugin/protocol.h \275 plugin/protocol.h \
273 plugin/qcache.h \276 plugin/qcache.h \
274 plugin/replicator.h \277 plugin/replicator.h \
275278
=== modified file 'drizzled/drizzled.cc'
--- drizzled/drizzled.cc 2009-07-16 19:30:03 +0000
+++ drizzled/drizzled.cc 2009-07-18 18:11:42 +0000
@@ -2326,10 +2326,7 @@
2326#endif2326#endif
23272327
2328 /* Print out all the options including plugin supplied options */2328 /* Print out all the options including plugin supplied options */
2329 my_print_help_inc_plugins(my_long_options, sizeof(my_long_options)/sizeof(my_option));2329 my_print_help_inc_plugins(my_long_options);
2330
2331 puts(_("\nTo see what values a running Drizzle server is using, type\n"
2332 "'drizzleadmin variables' instead of 'drizzled --help'."));
2333 }2330 }
2334}2331}
23352332
23362333
=== modified file 'drizzled/plugin.h'
--- drizzled/plugin.h 2009-07-07 09:06:29 +0000
+++ drizzled/plugin.h 2009-07-15 21:30:33 +0000
@@ -31,40 +31,28 @@
31*/31*/
3232
3333
34/* We use the following strings to define licenses for plugins */
35enum plugin_license_type {
36 PLUGIN_LICENSE_PROPRIETARY,
37 PLUGIN_LICENSE_GPL,
38 PLUGIN_LICENSE_BSD,
39 PLUGIN_LICENSE_LGPL,
40 PLUGIN_LICENSE_MAX=PLUGIN_LICENSE_LGPL
41};
42
43const char * const PLUGIN_LICENSE_PROPRIETARY_STRING="PROPRIETARY";
44const char * const PLUGIN_LICENSE_GPL_STRING="GPL";
45const char * const PLUGIN_LICENSE_BSD_STRING="BSD";
46const char * const PLUGIN_LICENSE_LGPL_STRING="LGPL";
47
48/*34/*
49 Macros for beginning and ending plugin declarations. Between35 Macros for beginning and ending plugin declarations. Between
50 drizzle_declare_plugin and drizzle_declare_plugin_end there should36 drizzle_declare_plugin and drizzle_declare_plugin_end there should
51 be a drizzled_plugin_manifest struct for each plugin to be declared.37 be a drizzled::plugin::Manifest for each plugin to be declared.
52*/38*/
5339
5440
55#ifndef DRIZZLE_DYNAMIC_PLUGIN41#ifndef DRIZZLE_DYNAMIC_PLUGIN
56#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \42#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
57struct drizzled_plugin_manifest DECLS[]= {43drizzled::plugin::Manifest DECLS[]= {
58#else44#else
59#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \45#define __DRIZZLE_DECLARE_PLUGIN(NAME, DECLS) \
60struct drizzled_plugin_manifest _mysql_plugin_declarations_[]= {46drizzled::plugin::Manifest _drizzled_plugin_declaration_[]= {
61#endif47#endif
6248
63#define drizzle_declare_plugin(NAME) \49#define drizzle_declare_plugin(NAME) \
64__DRIZZLE_DECLARE_PLUGIN(NAME, \50__DRIZZLE_DECLARE_PLUGIN(NAME, \
65 builtin_ ## NAME ## _plugin)51 builtin_ ## NAME ## _plugin)
6652
67#define drizzle_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0}}53#define drizzle_declare_plugin_end ,{0,0,0,0,PLUGIN_LICENSE_GPL,0,0,0,0,0}}
54
55
6856
69/*57/*
70 the following flags are valid for plugin_init()58 the following flags are valid for plugin_init()
7159
=== added file 'drizzled/plugin/handle.h'
--- drizzled/plugin/handle.h 1970-01-01 00:00:00 +0000
+++ drizzled/plugin/handle.h 2009-07-16 00:24:27 +0000
@@ -0,0 +1,68 @@
1/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 *
4 * Copyright (C) 2009 Sun Microsystems
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifndef DRIZZLED_PLUGIN_HANDLE_H
21#define DRIZZLED_PLUGIN_HANDLE_H
22
23#include <drizzled/lex_string.h>
24#include <mysys/my_alloc.h>
25
26class sys_var;
27
28namespace drizzled
29{
30namespace plugin
31{
32
33class Manifest;
34class Library;
35
36/* A handle of a plugin */
37class Handle
38{
39 const std::string name;
40 Manifest *manifest;
41public:
42 Library *plugin_dl;
43 bool isInited;
44 MEM_ROOT mem_root; /* memory for dynamic plugin structures */
45 sys_var *system_vars; /* server variables for this plugin */
46 Handle(Manifest *manifest_arg, Library *library_arg)
47 : name(manifest_arg->name), manifest(manifest_arg), plugin_dl(library_arg),
48 mem_root(), system_vars(NULL) {}
49
50 Handle(Manifest *manifest_arg)
51 : name(manifest_arg->name), manifest(manifest_arg), plugin_dl(NULL),
52 mem_root(), system_vars(NULL) {}
53
54 const std::string& getName() const
55 {
56 return name;
57 }
58
59 const Manifest& getManifest() const
60 {
61 return *manifest;
62 }
63};
64
65} /* namespace plugin */
66} /* namespace drizzled */
67
68#endif /* DRIZZLED_PLUGIN_HANDLE_H */
069
=== added file 'drizzled/plugin/library.h'
--- drizzled/plugin/library.h 1970-01-01 00:00:00 +0000
+++ drizzled/plugin/library.h 2009-07-15 21:47:32 +0000
@@ -0,0 +1,45 @@
1/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 *
4 * Copyright (C) 2009 Sun Microsystems
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifndef DRIZZLED_PLUGIN_LIBRARY_H
21#define DRIZZLED_PLUGIN_LIBRARY_H
22
23#include <drizzled/lex_string.h>
24
25namespace drizzled
26{
27namespace plugin
28{
29
30class Manifest;
31
32/* A handle for the dynamic library containing a plugin or plugins. */
33class Library
34{
35public:
36 LEX_STRING dl;
37 void *handle;
38 Manifest *plugins;
39 Library() : dl(), handle(NULL), plugins(NULL) {}
40};
41
42} /* namespace plugin */
43} /* namespace drizzled */
44
45#endif /* DRIZZLED_PLUGIN_LIBRARY_H */
046
=== added file 'drizzled/plugin/manifest.h'
--- drizzled/plugin/manifest.h 1970-01-01 00:00:00 +0000
+++ drizzled/plugin/manifest.h 2009-07-16 00:24:27 +0000
@@ -0,0 +1,75 @@
1/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 *
4 * Copyright (C) 2009 Sun Microsystems
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifndef DRIZZLED_PLUGIN_MANIFEST_H
21#define DRIZZLED_PLUGIN_MANIFEST_H
22
23#include <drizzled/plugin_registry.h>
24
25struct st_mysql_show_var;
26struct st_mysql_sys_var;
27
28/* We use the following strings to define licenses for plugins */
29enum plugin_license_type {
30 PLUGIN_LICENSE_GPL,
31 PLUGIN_LICENSE_BSD,
32 PLUGIN_LICENSE_LGPL,
33 PLUGIN_LICENSE_PROPRIETARY,
34 PLUGIN_LICENSE_MAX=PLUGIN_LICENSE_LGPL
35};
36
37
38namespace drizzled
39{
40namespace plugin
41{
42
43static const std::string LICENSE_GPL_STRING("GPL");
44static const std::string LICENSE_BSD_STRING("BSD");
45static const std::string LICENSE_LGPL_STRING("LGPL");
46static const std::string LICENSE_PROPRIETARY_STRING("PROPRIETARY");
47
48typedef int (*initialize_func_t)(PluginRegistry &);
49
50/**
51 * Plugin Manfiest
52 *
53 * One Manifest is required per plugin library which is to be dlopened
54 *
55 * This is a struct and not a class because it is staticly defined in the
56 * plugin objects and needs to be a POD as it can, or else it won't compile.
57 */
58struct Manifest
59{
60 const char *name; /* plugin name (for SHOW PLUGINS) */
61 const char *version; /* plugin version (for SHOW PLUGINS) */
62 const char *author; /* plugin author (for SHOW PLUGINS) */
63 const char *descr; /* general descriptive text (for SHOW PLUGINS ) */
64 plugin_license_type license; /* plugin license (PLUGIN_LICENSE_XXX) */
65 initialize_func_t init; /* function to invoke when plugin is loaded */
66 initialize_func_t deinit; /* function to invoke when plugin is unloaded */
67 st_mysql_show_var *status_vars;
68 st_mysql_sys_var **system_vars;
69 void *reserved1; /* reserved for dependency checking */
70};
71
72} /* namespace plugin */
73} /* namespace drizzled */
74
75#endif /* DRIZZLED_PLUGIN_MANIFEST_H */
076
=== modified file 'drizzled/plugin_registry.cc'
--- drizzled/plugin_registry.cc 2009-06-17 18:39:44 +0000
+++ drizzled/plugin_registry.cc 2009-07-16 00:24:27 +0000
@@ -45,21 +45,21 @@
45 return the_registry;45 return the_registry;
46}46}
4747
48st_plugin_int *PluginRegistry::find(const LEX_STRING *name)48drizzled::plugin::Handle *PluginRegistry::find(const LEX_STRING *name)
49{49{
50 string find_str(name->str,name->length);50 string find_str(name->str,name->length);
51 transform(find_str.begin(), find_str.end(), find_str.begin(), ::tolower);51 transform(find_str.begin(), find_str.end(), find_str.begin(), ::tolower);
5252
53 map<string, st_plugin_int *>::iterator map_iter;53 map<string, drizzled::plugin::Handle *>::iterator map_iter;
54 map_iter= plugin_map.find(find_str);54 map_iter= plugin_map.find(find_str);
55 if (map_iter != plugin_map.end())55 if (map_iter != plugin_map.end())
56 return (*map_iter).second;56 return (*map_iter).second;
57 return(0);57 return(0);
58}58}
5959
60void PluginRegistry::add(st_plugin_int *plugin)60void PluginRegistry::add(drizzled::plugin::Handle *plugin)
61{61{
62 string add_str(plugin->name.str);62 string add_str(plugin->getName());
63 transform(add_str.begin(), add_str.end(),63 transform(add_str.begin(), add_str.end(),
64 add_str.begin(), ::tolower);64 add_str.begin(), ::tolower);
6565
@@ -67,14 +67,14 @@
67}67}
6868
6969
70vector<st_plugin_int *> PluginRegistry::get_list(bool active)70vector<drizzled::plugin::Handle *> PluginRegistry::get_list(bool active)
71{71{
72 st_plugin_int *plugin= NULL;72 drizzled::plugin::Handle *plugin= NULL;
7373
74 vector <st_plugin_int *> plugins;74 vector <drizzled::plugin::Handle *> plugins;
75 plugins.reserve(plugin_map.size());75 plugins.reserve(plugin_map.size());
7676
77 map<string, st_plugin_int *>::iterator map_iter;77 map<string, drizzled::plugin::Handle *>::iterator map_iter;
78 for (map_iter= plugin_map.begin();78 for (map_iter= plugin_map.begin();
79 map_iter != plugin_map.end();79 map_iter != plugin_map.end();
80 map_iter++)80 map_iter++)
8181
=== modified file 'drizzled/plugin_registry.h'
--- drizzled/plugin_registry.h 2009-06-26 06:25:57 +0000
+++ drizzled/plugin_registry.h 2009-07-15 21:00:16 +0000
@@ -25,7 +25,6 @@
25#include <vector>25#include <vector>
26#include <map>26#include <map>
2727
28struct st_plugin_int;
29class StorageEngine;28class StorageEngine;
30class InfoSchemaTable;29class InfoSchemaTable;
31class Function_builder;30class Function_builder;
@@ -40,13 +39,14 @@
40namespace plugin39namespace plugin
41{40{
42class Replicator;41class Replicator;
42class Handle;
43}43}
44}44}
4545
46class PluginRegistry46class PluginRegistry
47{47{
48private:48private:
49 std::map<std::string, st_plugin_int *>49 std::map<std::string, drizzled::plugin::Handle *>
50 plugin_map;50 plugin_map;
5151
52 PluginRegistry(const PluginRegistry&);52 PluginRegistry(const PluginRegistry&);
@@ -54,11 +54,11 @@
54 PluginRegistry() {}54 PluginRegistry() {}
5555
5656
57 st_plugin_int *find(const LEX_STRING *name);57 drizzled::plugin::Handle *find(const LEX_STRING *name);
5858
59 void add(st_plugin_int *plugin);59 void add(drizzled::plugin::Handle *plugin);
6060
61 std::vector<st_plugin_int *> get_list(bool active);61 std::vector<drizzled::plugin::Handle *> get_list(bool active);
62 static PluginRegistry& getPluginRegistry();62 static PluginRegistry& getPluginRegistry();
6363
64 void add(StorageEngine *engine);64 void add(StorageEngine *engine);
6565
=== modified file 'drizzled/sql_plugin.cc'
--- drizzled/sql_plugin.cc 2009-06-30 21:28:16 +0000
+++ drizzled/sql_plugin.cc 2009-07-16 17:37:03 +0000
@@ -43,19 +43,21 @@
43#define REPORT_TO_USER 243#define REPORT_TO_USER 2
4444
45using namespace std;45using namespace std;
46using namespace drizzled;
47using namespace drizzled::plugin;
46 48
47typedef struct drizzled_plugin_manifest builtin_plugin[];49typedef Manifest builtin_plugin[];
48extern builtin_plugin DRIZZLED_BUILTIN_LIST;50extern builtin_plugin DRIZZLED_BUILTIN_LIST;
49static drizzled_plugin_manifest *drizzled_builtins[]=51static Manifest *drizzled_builtins[]=
50{52{
51 DRIZZLED_BUILTIN_LIST,(struct drizzled_plugin_manifest *)053 DRIZZLED_BUILTIN_LIST,(Manifest *)0
52};54};
5355
54char *opt_plugin_load= NULL;56char *opt_plugin_load= NULL;
55const char *opt_plugin_load_default= QUOTE_ARG(DRIZZLED_PLUGIN_LIST);57const char *opt_plugin_load_default= QUOTE_ARG(DRIZZLED_PLUGIN_LIST);
56char *opt_plugin_dir_ptr;58char *opt_plugin_dir_ptr;
57char opt_plugin_dir[FN_REFLEN];59char opt_plugin_dir[FN_REFLEN];
58static const char *plugin_declarations_sym= "_mysql_plugin_declarations_";60static const char *plugin_declarations_sym= "_drizzled_plugin_declaration_";
5961
60/* Note that 'int version' must be the first field of every plugin62/* Note that 'int version' must be the first field of every plugin
61 sub-structure (plugin->info).63 sub-structure (plugin->info).
@@ -122,7 +124,7 @@
122class sys_var_pluginvar: public sys_var124class sys_var_pluginvar: public sys_var
123{125{
124public:126public:
125 struct st_plugin_int *plugin;127 Handle *plugin;
126 struct st_mysql_sys_var *plugin_var;128 struct st_mysql_sys_var *plugin_var;
127129
128 static void *operator new(size_t size, MEM_ROOT *mem_root)130 static void *operator new(size_t size, MEM_ROOT *mem_root)
@@ -154,10 +156,10 @@
154/* prototypes */156/* prototypes */
155static bool plugin_load_list(MEM_ROOT *tmp_root, int *argc, char **argv,157static bool plugin_load_list(MEM_ROOT *tmp_root, int *argc, char **argv,
156 const char *list);158 const char *list);
157static int test_plugin_options(MEM_ROOT *, struct st_plugin_int *,159static int test_plugin_options(MEM_ROOT *, Handle *,
158 int *, char **);160 int *, char **);
159static bool register_builtin(struct st_plugin_int *,161static bool register_builtin(Handle *,
160 struct st_plugin_int **);162 Handle **);
161static void unlock_variables(Session *session, struct system_variables *vars);163static void unlock_variables(Session *session, struct system_variables *vars);
162static void cleanup_variables(Session *session, struct system_variables *vars);164static void cleanup_variables(Session *session, struct system_variables *vars);
163static void plugin_vars_free_values(sys_var *vars);165static void plugin_vars_free_values(sys_var *vars);
@@ -236,14 +238,14 @@
236 Plugin support code238 Plugin support code
237****************************************************************************/239****************************************************************************/
238240
239static struct st_plugin_dl *plugin_dl_find(const LEX_STRING *dl)241static Library *plugin_dl_find(const LEX_STRING *dl)
240{242{
241 uint32_t i;243 uint32_t i;
242 struct st_plugin_dl *tmp;244 Library *tmp;
243245
244 for (i= 0; i < plugin_dl_array.elements; i++)246 for (i= 0; i < plugin_dl_array.elements; i++)
245 {247 {
246 tmp= *dynamic_element(&plugin_dl_array, i, struct st_plugin_dl **);248 tmp= *dynamic_element(&plugin_dl_array, i, Library **);
247 if (! my_strnncoll(files_charset_info,249 if (! my_strnncoll(files_charset_info,
248 (const unsigned char *)dl->str, dl->length,250 (const unsigned char *)dl->str, dl->length,
249 (const unsigned char *)tmp->dl.str, tmp->dl.length))251 (const unsigned char *)tmp->dl.str, tmp->dl.length))
@@ -252,29 +254,29 @@
252 return(0);254 return(0);
253}255}
254256
255static st_plugin_dl *plugin_dl_insert_or_reuse(struct st_plugin_dl *plugin_dl)257static Library *plugin_dl_insert_or_reuse(Library *plugin_dl)
256{258{
257 uint32_t i;259 uint32_t i;
258 struct st_plugin_dl *tmp;260 Library *tmp;
259261
260 for (i= 0; i < plugin_dl_array.elements; i++)262 for (i= 0; i < plugin_dl_array.elements; i++)
261 {263 {
262 tmp= *dynamic_element(&plugin_dl_array, i, struct st_plugin_dl **);264 tmp= *dynamic_element(&plugin_dl_array, i, Library **);
263 {265 {
264 memcpy(tmp, plugin_dl, sizeof(struct st_plugin_dl));266 memcpy(tmp, plugin_dl, sizeof(Library));
265 return(tmp);267 return(tmp);
266 }268 }
267 }269 }
268 if (insert_dynamic(&plugin_dl_array, (unsigned char*)&plugin_dl))270 if (insert_dynamic(&plugin_dl_array, (unsigned char*)&plugin_dl))
269 return(0);271 return(0);
270 tmp= *dynamic_element(&plugin_dl_array, plugin_dl_array.elements - 1,272 tmp= *dynamic_element(&plugin_dl_array, plugin_dl_array.elements - 1,
271 struct st_plugin_dl **)=273 Library **)=
272 (struct st_plugin_dl *) memdup_root(&plugin_mem_root, (unsigned char*)plugin_dl,274 (Library *) memdup_root(&plugin_mem_root, (unsigned char*)plugin_dl,
273 sizeof(struct st_plugin_dl));275 sizeof(Library));
274 return(tmp);276 return(tmp);
275}277}
276278
277static inline void free_plugin_mem(struct st_plugin_dl *p)279static inline void free_plugin_mem(Library *p)
278{280{
279 if (p->handle)281 if (p->handle)
280 dlclose(p->handle);282 dlclose(p->handle);
@@ -282,11 +284,11 @@
282}284}
283285
284286
285static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report)287static Library *plugin_dl_add(const LEX_STRING *dl, int report)
286{288{
287 string dlpath;289 string dlpath;
288 uint32_t plugin_dir_len;290 uint32_t plugin_dir_len;
289 struct st_plugin_dl *tmp, plugin_dl;291 Library *tmp, plugin_dl;
290 void *sym;292 void *sym;
291 plugin_dir_len= strlen(opt_plugin_dir);293 plugin_dir_len= strlen(opt_plugin_dir);
292 dlpath.reserve(FN_REFLEN);294 dlpath.reserve(FN_REFLEN);
@@ -345,7 +347,7 @@
345 return(0);347 return(0);
346 }348 }
347349
348 plugin_dl.plugins= (struct drizzled_plugin_manifest *)sym;350 plugin_dl.plugins= static_cast<Manifest *>(sym);
349351
350 /* Duplicate and convert dll name */352 /* Duplicate and convert dll name */
351 plugin_dl.dl.length= dl->length * files_charset_info->mbmaxlen + 1;353 plugin_dl.dl.length= dl->length * files_charset_info->mbmaxlen + 1;
@@ -364,9 +366,9 @@
364 {366 {
365 free_plugin_mem(&plugin_dl);367 free_plugin_mem(&plugin_dl);
366 if (report & REPORT_TO_USER)368 if (report & REPORT_TO_USER)
367 my_error(ER_OUTOFMEMORY, MYF(0), sizeof(struct st_plugin_dl));369 my_error(ER_OUTOFMEMORY, MYF(0), sizeof(Library));
368 if (report & REPORT_TO_LOG)370 if (report & REPORT_TO_LOG)
369 errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_OUTOFMEMORY), sizeof(struct st_plugin_dl));371 errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_OUTOFMEMORY), sizeof(Library));
370 return(0);372 return(0);
371 }373 }
372 return(tmp);374 return(tmp);
@@ -379,8 +381,8 @@
379381
380 for (i= 0; i < plugin_dl_array.elements; i++)382 for (i= 0; i < plugin_dl_array.elements; i++)
381 {383 {
382 struct st_plugin_dl *tmp= *dynamic_element(&plugin_dl_array, i,384 Library *tmp= *dynamic_element(&plugin_dl_array, i,
383 struct st_plugin_dl **);385 Library **);
384 if (! my_strnncoll(files_charset_info,386 if (! my_strnncoll(files_charset_info,
385 (const unsigned char *)dl->str, dl->length,387 (const unsigned char *)dl->str, dl->length,
386 (const unsigned char *)tmp->dl.str, tmp->dl.length))388 (const unsigned char *)tmp->dl.str, tmp->dl.length))
@@ -388,7 +390,7 @@
388 /* Do not remove this element, unless no other plugin uses this dll. */390 /* Do not remove this element, unless no other plugin uses this dll. */
389 {391 {
390 free_plugin_mem(tmp);392 free_plugin_mem(tmp);
391 memset(tmp, 0, sizeof(struct st_plugin_dl));393 memset(tmp, 0, sizeof(Library));
392 }394 }
393 break;395 break;
394 }396 }
@@ -398,16 +400,13 @@
398400
399401
400402
401static st_plugin_int *plugin_insert_or_reuse(struct st_plugin_int *plugin)403static Handle *plugin_insert_or_reuse(Handle *plugin)
402{404{
403 struct st_plugin_int *tmp;
404 if (insert_dynamic(&plugin_array, (unsigned char*)&plugin))405 if (insert_dynamic(&plugin_array, (unsigned char*)&plugin))
405 return(0);406 return(0);
406 tmp= *dynamic_element(&plugin_array, plugin_array.elements - 1,407 plugin= *dynamic_element(&plugin_array, plugin_array.elements - 1,
407 struct st_plugin_int **)=408 Handle **);
408 (struct st_plugin_int *) memdup_root(&plugin_mem_root, (unsigned char*)plugin,409 return(plugin);
409 sizeof(struct st_plugin_int));
410 return(tmp);
411}410}
412411
413412
@@ -421,8 +420,7 @@
421{420{
422 PluginRegistry &registry= PluginRegistry::getPluginRegistry();421 PluginRegistry &registry= PluginRegistry::getPluginRegistry();
423422
424 struct st_plugin_int tmp;423 Manifest *manifest;
425 struct drizzled_plugin_manifest *plugin;
426 if (! initialized)424 if (! initialized)
427 return(0);425 return(0);
428426
@@ -434,34 +432,32 @@
434 errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_UDF_EXISTS), name->str);432 errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_UDF_EXISTS), name->str);
435 return(true);433 return(true);
436 }434 }
437 /* Clear the whole struct to catch future extensions. */435 Library *library= plugin_dl_add(dl, report);
438 memset(&tmp, 0, sizeof(tmp));436 if (library == NULL)
439 if (! (tmp.plugin_dl= plugin_dl_add(dl, report)))437 return true;
440 return(true);438
439 Handle *tmp= NULL;
441 /* Find plugin by name */440 /* Find plugin by name */
442 for (plugin= tmp.plugin_dl->plugins; plugin->name; plugin++)441 for (manifest= library->plugins; manifest->name; manifest++)
443 {442 {
444 uint32_t name_len= strlen(plugin->name);
445 if (! my_strnncoll(system_charset_info,443 if (! my_strnncoll(system_charset_info,
446 (const unsigned char *)name->str, name->length,444 (const unsigned char *)name->str, name->length,
447 (const unsigned char *)plugin->name,445 (const unsigned char *)manifest->name,
448 name_len))446 strlen(manifest->name)))
449 {447 {
450 struct st_plugin_int *tmp_plugin_ptr;448 tmp= new (std::nothrow) Handle(manifest, library);
449 if (tmp == NULL)
450 return true;
451451
452 tmp.plugin= plugin;452 if (!test_plugin_options(tmp_root, tmp, argc, argv))
453 tmp.name.str= (char *)plugin->name;
454 tmp.name.length= name_len;
455 tmp.isInited= false;
456 if (!test_plugin_options(tmp_root, &tmp, argc, argv))
457 {453 {
458 if ((tmp_plugin_ptr= plugin_insert_or_reuse(&tmp)))454 if ((tmp= plugin_insert_or_reuse(tmp)))
459 {455 {
460 registry.add(tmp_plugin_ptr);456 registry.add(tmp);
461 init_alloc_root(&tmp_plugin_ptr->mem_root, 4096, 4096);457 init_alloc_root(&tmp->mem_root, 4096, 4096);
462 return(false);458 return(false);
463 }459 }
464 mysql_del_sys_var_chain(tmp.system_vars);460 mysql_del_sys_var_chain(tmp->system_vars);
465 goto err;461 goto err;
466 }462 }
467 /* plugin was disabled */463 /* plugin was disabled */
@@ -479,18 +475,18 @@
479}475}
480476
481477
482static void plugin_del(struct st_plugin_int *plugin)478static void plugin_del(Handle *plugin)
483{479{
484 PluginRegistry &registry= PluginRegistry::getPluginRegistry();480 PluginRegistry &registry= PluginRegistry::getPluginRegistry();
485 if (plugin->isInited)481 if (plugin->isInited)
486 {482 {
487 if (plugin->plugin->status_vars)483 if (plugin->getManifest().status_vars)
488 {484 {
489 remove_status_vars(plugin->plugin->status_vars);485 remove_status_vars(plugin->getManifest().status_vars);
490 }486 }
491487
492 if (plugin->plugin->deinit)488 if (plugin->getManifest().deinit)
493 plugin->plugin->deinit(registry);489 plugin->getManifest().deinit(registry);
494 }490 }
495491
496 /* Free allocated strings before deleting the plugin. */492 /* Free allocated strings before deleting the plugin. */
@@ -501,44 +497,44 @@
501 pthread_rwlock_wrlock(&LOCK_system_variables_hash);497 pthread_rwlock_wrlock(&LOCK_system_variables_hash);
502 mysql_del_sys_var_chain(plugin->system_vars);498 mysql_del_sys_var_chain(plugin->system_vars);
503 pthread_rwlock_unlock(&LOCK_system_variables_hash);499 pthread_rwlock_unlock(&LOCK_system_variables_hash);
504 free_root(&plugin->mem_root, MYF(0));500 delete plugin;
505}501}
506502
507static void reap_plugins(void)503static void reap_plugins(void)
508{504{
509 size_t count;505 size_t count;
510 uint32_t idx;506 uint32_t idx;
511 struct st_plugin_int *plugin;507 drizzled::plugin::Handle *plugin;
512508
513 count= plugin_array.elements;509 count= plugin_array.elements;
514510
515 for (idx= 0; idx < count; idx++)511 for (idx= 0; idx < count; idx++)
516 {512 {
517 plugin= *dynamic_element(&plugin_array, idx, struct st_plugin_int **);513 plugin= *dynamic_element(&plugin_array, idx, drizzled::plugin::Handle **);
518 plugin_del(plugin);514 plugin_del(plugin);
519 }515 }
520}516}
521517
522static bool plugin_initialize(struct st_plugin_int *plugin)518static bool plugin_initialize(drizzled::plugin::Handle *plugin)
523{519{
524 assert(plugin->isInited == false);520 assert(plugin->isInited == false);
525521
526 PluginRegistry &registry= PluginRegistry::getPluginRegistry();522 PluginRegistry &registry= PluginRegistry::getPluginRegistry();
527 if (plugin->plugin->init)523 if (plugin->getManifest().init)
528 {524 {
529 if (plugin->plugin->init(registry))525 if (plugin->getManifest().init(registry))
530 {526 {
531 errmsg_printf(ERRMSG_LVL_ERROR,527 errmsg_printf(ERRMSG_LVL_ERROR,
532 _("Plugin '%s' init function returned error.\n"),528 _("Plugin '%s' init function returned error.\n"),
533 plugin->name.str);529 plugin->getName().c_str());
534 goto err;530 goto err;
535 }531 }
536 }532 }
537 plugin->isInited= true;533 plugin->isInited= true;
538534
539 if (plugin->plugin->status_vars)535 if (plugin->getManifest().status_vars)
540 {536 {
541 add_status_vars(plugin->plugin->status_vars); // add_status_vars makes a copy537 add_status_vars(plugin->getManifest().status_vars); // add_status_vars makes a copy
542 }538 }
543539
544 /*540 /*
@@ -584,9 +580,9 @@
584int plugin_init(int *argc, char **argv, int flags)580int plugin_init(int *argc, char **argv, int flags)
585{581{
586 uint32_t idx;582 uint32_t idx;
587 struct drizzled_plugin_manifest **builtins;583 Manifest **builtins;
588 struct drizzled_plugin_manifest *plugin;584 Manifest *manifest;
589 struct st_plugin_int tmp, *plugin_ptr;585 Handle *handle;
590 MEM_ROOT tmp_root;586 MEM_ROOT tmp_root;
591587
592 if (initialized)588 if (initialized)
@@ -601,9 +597,9 @@
601597
602598
603 if (my_init_dynamic_array(&plugin_dl_array,599 if (my_init_dynamic_array(&plugin_dl_array,
604 sizeof(struct st_plugin_dl *),16,16) ||600 sizeof(Library *),16,16) ||
605 my_init_dynamic_array(&plugin_array,601 my_init_dynamic_array(&plugin_array,
606 sizeof(struct st_plugin_int *),16,16))602 sizeof(Handle *),16,16))
607 goto err;603 goto err;
608604
609 initialized= 1;605 initialized= 1;
@@ -613,21 +609,20 @@
613 */609 */
614 for (builtins= drizzled_builtins; *builtins; builtins++)610 for (builtins= drizzled_builtins; *builtins; builtins++)
615 {611 {
616 for (plugin= *builtins; plugin->name; plugin++)612 for (manifest= *builtins; manifest->name; manifest++)
617 {613 {
618 memset(&tmp, 0, sizeof(tmp));614 handle= new (std::nothrow) Handle(manifest);
619 tmp.plugin= plugin;615 if (handle == NULL)
620 tmp.name.str= (char *)plugin->name;616 return true;
621 tmp.name.length= strlen(plugin->name);
622617
623 free_root(&tmp_root, MYF(MY_MARK_BLOCKS_FREE));618 free_root(&tmp_root, MYF(MY_MARK_BLOCKS_FREE));
624 if (test_plugin_options(&tmp_root, &tmp, argc, argv))619 if (test_plugin_options(&tmp_root, handle, argc, argv))
625 continue;620 continue;
626621
627 if (register_builtin(&tmp, &plugin_ptr))622 if (register_builtin(handle, &handle))
628 goto err_unlock;623 goto err_unlock;
629624
630 if (plugin_initialize(plugin_ptr))625 if (plugin_initialize(handle))
631 goto err_unlock;626 goto err_unlock;
632627
633 }628 }
@@ -649,11 +644,11 @@
649 */644 */
650 for (idx= 0; idx < plugin_array.elements; idx++)645 for (idx= 0; idx < plugin_array.elements; idx++)
651 {646 {
652 plugin_ptr= *dynamic_element(&plugin_array, idx, struct st_plugin_int **);647 handle= *dynamic_element(&plugin_array, idx, Handle **);
653 if (plugin_ptr->isInited == false)648 if (handle->isInited == false)
654 {649 {
655 if (plugin_initialize(plugin_ptr))650 if (plugin_initialize(handle))
656 plugin_del(plugin_ptr);651 plugin_del(handle);
657 }652 }
658 }653 }
659654
@@ -670,8 +665,8 @@
670}665}
671666
672667
673static bool register_builtin(struct st_plugin_int *tmp,668static bool register_builtin(Handle *tmp,
674 struct st_plugin_int **ptr)669 Handle **ptr)
675{670{
676671
677 PluginRegistry &registry= PluginRegistry::getPluginRegistry();672 PluginRegistry &registry= PluginRegistry::getPluginRegistry();
@@ -683,9 +678,7 @@
683 return(1);678 return(1);
684679
685 *ptr= *dynamic_element(&plugin_array, plugin_array.elements - 1,680 *ptr= *dynamic_element(&plugin_array, plugin_array.elements - 1,
686 struct st_plugin_int **)=681 Handle **);
687 (struct st_plugin_int *) memdup_root(&plugin_mem_root, (unsigned char*)tmp,
688 sizeof(struct st_plugin_int));
689682
690 registry.add(*ptr);683 registry.add(*ptr);
691684
@@ -701,8 +694,8 @@
701{694{
702 char buffer[FN_REFLEN];695 char buffer[FN_REFLEN];
703 LEX_STRING name= {buffer, 0}, dl= {NULL, 0}, *str= &name;696 LEX_STRING name= {buffer, 0}, dl= {NULL, 0}, *str= &name;
704 struct st_plugin_dl *plugin_dl;697 Library *plugin_dl;
705 struct drizzled_plugin_manifest *plugin;698 Manifest *plugin;
706 char *p= buffer;699 char *p= buffer;
707 while (list)700 while (list)
708 {701 {
@@ -778,8 +771,8 @@
778{771{
779 uint32_t idx;772 uint32_t idx;
780 size_t count= plugin_array.elements;773 size_t count= plugin_array.elements;
781 vector<st_plugin_int *> plugins;774 vector<Handle *> plugins;
782 vector<st_plugin_dl *> dl;775 vector<Library *> dl;
783776
784 if (initialized)777 if (initialized)
785 {778 {
@@ -803,7 +796,7 @@
803 dl.reserve(count);796 dl.reserve(count);
804 for (idx= 0; idx < count; idx++)797 for (idx= 0; idx < count; idx++)
805 dl.push_back(*dynamic_element(&plugin_dl_array, idx,798 dl.push_back(*dynamic_element(&plugin_dl_array, idx,
806 struct st_plugin_dl **));799 Library **));
807 for (idx= 0; idx < count; idx++)800 for (idx= 0; idx < count; idx++)
808 free_plugin_mem(dl[idx]);801 free_plugin_mem(dl[idx]);
809 delete_dynamic(&plugin_dl_array);802 delete_dynamic(&plugin_dl_array);
@@ -1123,7 +1116,7 @@
1123{1116{
1124 sys_var *var;1117 sys_var *var;
1125 sys_var_pluginvar *pi= NULL;1118 sys_var_pluginvar *pi= NULL;
1126 st_plugin_int *plugin;1119 Handle *plugin;
11271120
1128 pthread_rwlock_rdlock(&LOCK_system_variables_hash);1121 pthread_rwlock_rdlock(&LOCK_system_variables_hash);
1129 if ((var= intern_find_sys_var(str, length, false)) &&1122 if ((var= intern_find_sys_var(str, length, false)) &&
@@ -1867,10 +1860,10 @@
1867}1860}
18681861
18691862
1870static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp,1863static int construct_options(MEM_ROOT *mem_root, Handle *tmp,
1871 my_option *options, bool can_disable)1864 my_option *options, bool can_disable)
1872{1865{
1873 const char *plugin_name= tmp->plugin->name;1866 const char *plugin_name= tmp->getManifest().name;
1874 uint32_t namelen= strlen(plugin_name), optnamelen;1867 uint32_t namelen= strlen(plugin_name), optnamelen;
1875 uint32_t buffer_length= namelen * 4 + (can_disable ? 75 : 10);1868 uint32_t buffer_length= namelen * 4 + (can_disable ? 75 : 10);
1876 char *name= (char*) alloc_root(mem_root, buffer_length) + 1;1869 char *name= (char*) alloc_root(mem_root, buffer_length) + 1;
@@ -1916,7 +1909,7 @@
1916 by my_getopt and register_var() in the first pass uses realloc1909 by my_getopt and register_var() in the first pass uses realloc
1917 */1910 */
19181911
1919 for (plugin_option= tmp->plugin->system_vars;1912 for (plugin_option= tmp->getManifest().system_vars;
1920 plugin_option && *plugin_option; plugin_option++, index++)1913 plugin_option && *plugin_option; plugin_option++, index++)
1921 {1914 {
1922 opt= *plugin_option;1915 opt= *plugin_option;
@@ -1953,7 +1946,7 @@
1953 };1946 };
1954 }1947 }
19551948
1956 for (plugin_option= tmp->plugin->system_vars;1949 for (plugin_option= tmp->getManifest().system_vars;
1957 plugin_option && *plugin_option; plugin_option++, index++)1950 plugin_option && *plugin_option; plugin_option++, index++)
1958 {1951 {
1959 switch ((opt= *plugin_option)->flags & PLUGIN_VAR_TYPEMASK) {1952 switch ((opt= *plugin_option)->flags & PLUGIN_VAR_TYPEMASK) {
@@ -2082,24 +2075,24 @@
2082}2075}
20832076
20842077
2085static my_option *construct_help_options(MEM_ROOT *mem_root,2078static my_option *construct_help_options(MEM_ROOT *mem_root, Handle *p)
2086 struct st_plugin_int *p)
2087{2079{
2088 st_mysql_sys_var **opt;2080 st_mysql_sys_var **opt;
2089 my_option *opts;2081 my_option *opts;
2090 bool can_disable;2082 bool can_disable;
2091 uint32_t count= EXTRA_OPTIONS;2083 uint32_t count= EXTRA_OPTIONS;
20922084
2093 for (opt= p->plugin->system_vars; opt && *opt; opt++, count+= 2) {};2085 for (opt= p->getManifest().system_vars; opt && *opt; opt++, count+= 2) {};
20942086
2095 if (!(opts= (my_option*) alloc_root(mem_root, sizeof(my_option) * count)))2087 opts= (my_option*)alloc_root(mem_root, (sizeof(my_option) * count));
2088 if (opts == NULL)
2096 return NULL;2089 return NULL;
20972090
2098 memset(opts, 0, sizeof(my_option) * count);2091 memset(opts, 0, sizeof(my_option) * count);
20992092
2100 if ((my_strcasecmp(&my_charset_utf8_general_ci, p->name.str, "MyISAM") == 0))2093 if ((my_strcasecmp(&my_charset_utf8_general_ci, p->getName().c_str(), "MyISAM") == 0))
2101 can_disable= false;2094 can_disable= false;
2102 else if ((my_strcasecmp(&my_charset_utf8_general_ci, p->name.str, "MEMORY") == 0))2095 else if ((my_strcasecmp(&my_charset_utf8_general_ci, p->getName().c_str(), "MEMORY") == 0))
2103 can_disable= false;2096 can_disable= false;
2104 else2097 else
2105 can_disable= true;2098 can_disable= true;
@@ -2125,7 +2118,7 @@
2125 NOTE:2118 NOTE:
2126 Requires that a write-lock is held on LOCK_system_variables_hash2119 Requires that a write-lock is held on LOCK_system_variables_hash
2127*/2120*/
2128static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp,2121static int test_plugin_options(MEM_ROOT *tmp_root, Handle *tmp,
2129 int *argc, char **argv)2122 int *argc, char **argv)
2130{2123{
2131 struct sys_var_chain chain= { NULL, NULL };2124 struct sys_var_chain chain= { NULL, NULL };
@@ -2140,14 +2133,13 @@
2140 sys_var *v;2133 sys_var *v;
2141 struct st_bookmark *var;2134 struct st_bookmark *var;
2142 uint32_t len, count= EXTRA_OPTIONS;2135 uint32_t len, count= EXTRA_OPTIONS;
2143 assert(tmp->plugin && tmp->name.str);
21442136
2145 for (opt= tmp->plugin->system_vars; opt && *opt; opt++)2137 for (opt= tmp->getManifest().system_vars; opt && *opt; opt++)
2146 count+= 2; /* --{plugin}-{optname} and --plugin-{plugin}-{optname} */2138 count+= 2; /* --{plugin}-{optname} and --plugin-{plugin}-{optname} */
21472139
2148 if ((my_strcasecmp(&my_charset_utf8_general_ci, tmp->name.str, "MyISAM") == 0))2140 if ((my_strcasecmp(&my_charset_utf8_general_ci, tmp->getName().c_str(), "MyISAM") == 0))
2149 can_disable= false;2141 can_disable= false;
2150 else if ((my_strcasecmp(&my_charset_utf8_general_ci, tmp->name.str, "MEMORY") == 0))2142 else if ((my_strcasecmp(&my_charset_utf8_general_ci, tmp->getName().c_str(), "MEMORY") == 0))
2151 can_disable= false;2143 can_disable= false;
2152 else2144 else
2153 can_disable= true;2145 can_disable= true;
@@ -2156,14 +2148,14 @@
2156 {2148 {
2157 if (!(opts= (my_option*) alloc_root(tmp_root, sizeof(my_option) * count)))2149 if (!(opts= (my_option*) alloc_root(tmp_root, sizeof(my_option) * count)))
2158 {2150 {
2159 errmsg_printf(ERRMSG_LVL_ERROR, _("Out of memory for plugin '%s'."), tmp->name.str);2151 errmsg_printf(ERRMSG_LVL_ERROR, _("Out of memory for plugin '%s'."), tmp->getName().c_str());
2160 return(-1);2152 return(-1);
2161 }2153 }
2162 memset(opts, 0, sizeof(my_option) * count);2154 memset(opts, 0, sizeof(my_option) * count);
21632155
2164 if (construct_options(tmp_root, tmp, opts, can_disable))2156 if (construct_options(tmp_root, tmp, opts, can_disable))
2165 {2157 {
2166 errmsg_printf(ERRMSG_LVL_ERROR, _("Bad options for plugin '%s'."), tmp->name.str);2158 errmsg_printf(ERRMSG_LVL_ERROR, _("Bad options for plugin '%s'."), tmp->getName().c_str());
2167 return(-1);2159 return(-1);
2168 }2160 }
21692161
@@ -2173,7 +2165,7 @@
2173 if (error)2165 if (error)
2174 {2166 {
2175 errmsg_printf(ERRMSG_LVL_ERROR, _("Parsing options for plugin '%s' failed."),2167 errmsg_printf(ERRMSG_LVL_ERROR, _("Parsing options for plugin '%s' failed."),
2176 tmp->name.str);2168 tmp->getName().c_str());
2177 goto err;2169 goto err;
2178 }2170 }
2179 }2171 }
@@ -2181,18 +2173,18 @@
2181 error= 1;2173 error= 1;
21822174
2183 {2175 {
2184 for (opt= tmp->plugin->system_vars; opt && *opt; opt++)2176 for (opt= tmp->getManifest().system_vars; opt && *opt; opt++)
2185 {2177 {
2186 if (((o= *opt)->flags & PLUGIN_VAR_NOSYSVAR))2178 if (((o= *opt)->flags & PLUGIN_VAR_NOSYSVAR))
2187 continue;2179 continue;
21882180
2189 if ((var= find_bookmark(tmp->name.str, o->name, o->flags)))2181 if ((var= find_bookmark(tmp->getName().c_str(), o->name, o->flags)))
2190 v= new (mem_root) sys_var_pluginvar(var->key + 1, o);2182 v= new (mem_root) sys_var_pluginvar(var->key + 1, o);
2191 else2183 else
2192 {2184 {
2193 len= tmp->name.length + strlen(o->name) + 2;2185 len= tmp->getName().length() + strlen(o->name) + 2;
2194 varname= (char*) alloc_root(mem_root, len);2186 varname= (char*) alloc_root(mem_root, len);
2195 sprintf(varname,"%s-%s",tmp->name.str,o->name);2187 sprintf(varname,"%s-%s",tmp->getName().c_str(),o->name);
2196 my_casedn_str(&my_charset_utf8_general_ci, varname);2188 my_casedn_str(&my_charset_utf8_general_ci, varname);
21972189
2198 for (p= varname; *p; p++)2190 for (p= varname; *p; p++)
@@ -2216,7 +2208,7 @@
2216 if (mysql_add_sys_var_chain(chain.first, NULL))2208 if (mysql_add_sys_var_chain(chain.first, NULL))
2217 {2209 {
2218 errmsg_printf(ERRMSG_LVL_ERROR, _("Plugin '%s' has conflicting system variables"),2210 errmsg_printf(ERRMSG_LVL_ERROR, _("Plugin '%s' has conflicting system variables"),
2219 tmp->name.str);2211 tmp->getName().c_str());
2220 goto err;2212 goto err;
2221 }2213 }
2222 tmp->system_vars= chain.first;2214 tmp->system_vars= chain.first;
@@ -2235,49 +2227,69 @@
2235 Help Verbose text with Plugin System Variables2227 Help Verbose text with Plugin System Variables
2236****************************************************************************/2228****************************************************************************/
22372229
2238static int option_cmp(my_option *a, my_option *b)2230class OptionCmp
2239{2231{
2240 return my_strcasecmp(&my_charset_utf8_general_ci, a->name, b->name);2232public:
2241}2233 bool operator() (const my_option &a, const my_option &b)
22422234 {
22432235 return my_strcasecmp(&my_charset_utf8_general_ci, a.name, b.name);
2244void my_print_help_inc_plugins(my_option *main_options, uint32_t size)2236 }
2245{2237};
2246 DYNAMIC_ARRAY all_options;2238
2247 struct st_plugin_int *p;2239
2240void my_print_help_inc_plugins(my_option *main_options)
2241{
2242 vector<my_option> all_options;
2243 Handle *p;
2248 MEM_ROOT mem_root;2244 MEM_ROOT mem_root;
2249 my_option *opt;2245 my_option *opt= NULL;
22502246
2251 init_alloc_root(&mem_root, 4096, 4096);2247 init_alloc_root(&mem_root, 4096, 4096);
2252 my_init_dynamic_array(&all_options, sizeof(my_option), size, size/4);
22532248
2254 if (initialized)2249 if (initialized)
2255 for (uint32_t idx= 0; idx < plugin_array.elements; idx++)2250 for (uint32_t idx= 0; idx < plugin_array.elements; idx++)
2256 {2251 {
2257 p= *dynamic_element(&plugin_array, idx, struct st_plugin_int **);2252 p= *dynamic_element(&plugin_array, idx, Handle **);
22582253
2259 if (!p->plugin->system_vars ||2254 if (p->getManifest().system_vars == NULL)
2260 !(opt= construct_help_options(&mem_root, p)))2255 continue;
2256
2257 opt= construct_help_options(&mem_root, p);
2258 if (opt == NULL)
2261 continue;2259 continue;
22622260
2263 /* Only options with a non-NULL comment are displayed in help text */2261 /* Only options with a non-NULL comment are displayed in help text */
2264 for (;opt->id; opt++)2262 for (;opt->id; opt++)
2263 {
2265 if (opt->comment)2264 if (opt->comment)
2266 insert_dynamic(&all_options, (unsigned char*) opt);2265 {
2266 all_options.push_back(*opt);
2267
2268 }
2269 }
2267 }2270 }
22682271
2269 for (;main_options->id; main_options++)2272 for (;main_options->id; main_options++)
2270 insert_dynamic(&all_options, (unsigned char*) main_options);2273 {
2274 if (main_options->comment)
2275 {
2276 all_options.push_back(*main_options);
2277 }
2278 }
22712279
2272 sort_dynamic(&all_options, (qsort_cmp) option_cmp);2280 /**
2281 * @TODO: Fix the my_option building so that it doens't break sort
2282 *
2283 * sort(all_options.begin(), all_options.end(), OptionCmp());
2284 */
22732285
2274 /* main_options now points to the empty option terminator */2286 /* main_options now points to the empty option terminator */
2275 insert_dynamic(&all_options, (unsigned char*) main_options);2287 all_options.push_back(*main_options);
22762288
2277 my_print_help((my_option*) all_options.buffer);2289 my_print_help(&*(all_options.begin()));
2278 my_print_variables((my_option*) all_options.buffer);2290 my_print_variables(&*(all_options.begin()));
22792291
2280 delete_dynamic(&all_options);
2281 free_root(&mem_root, MYF(0));2292 free_root(&mem_root, MYF(0));
2293
2282}2294}
22832295
22842296
=== modified file 'drizzled/sql_plugin.h'
--- drizzled/sql_plugin.h 2009-07-07 09:06:29 +0000
+++ drizzled/sql_plugin.h 2009-07-16 17:37:03 +0000
@@ -36,63 +36,15 @@
36#ifndef DRIZZLE_SERVER_PLUGIN_H36#ifndef DRIZZLE_SERVER_PLUGIN_H
37#define DRIZZLE_SERVER_PLUGIN_H37#define DRIZZLE_SERVER_PLUGIN_H
3838
39#include <drizzled/lex_string.h>
40#include <mysys/my_alloc.h>
41#include <drizzled/plugin_registry.h>
42#include <drizzled/plugin.h>39#include <drizzled/plugin.h>
40#include <drizzled/plugin/manifest.h>
41#include <drizzled/plugin/library.h>
42#include <drizzled/plugin/handle.h>
4343
44class Session;
44class sys_var;45class sys_var;
45class Session;46typedef struct st_mysql_lex_string LEX_STRING;
4647struct my_option;
47
48/* A handle for the dynamic library containing a plugin or plugins. */
49struct drizzled_plugin_manifest;
50
51struct st_plugin_dl
52{
53 LEX_STRING dl;
54 void *handle;
55 struct drizzled_plugin_manifest *plugins;
56};
57
58/* A handle of a plugin */
59
60struct st_plugin_int
61{
62 LEX_STRING name;
63 struct drizzled_plugin_manifest *plugin;
64 struct st_plugin_dl *plugin_dl;
65 bool isInited;
66 MEM_ROOT mem_root; /* memory for dynamic plugin structures */
67 sys_var *system_vars; /* server variables for this plugin */
68};
69
70
71#define plugin_decl(pi) ((pi)->plugin)
72#define plugin_data(pi,cast) (static_cast<cast>((pi)->data))
73#define plugin_name(pi) (&((pi)->name))
74#define plugin_equals(p1,p2) ((p1) && (p2) && (p1) == (p2))
75
76
77typedef int (*plugin_type_init)(PluginRegistry &);
78
79/*
80 Plugin description structure.
81*/
82
83struct drizzled_plugin_manifest
84{
85 const char *name; /* plugin name (for SHOW PLUGINS) */
86 const char *version; /* plugin version (for SHOW PLUGINS) */
87 const char *author; /* plugin author (for SHOW PLUGINS) */
88 const char *descr; /* general descriptive text (for SHOW PLUGINS ) */
89 int license; /* plugin license (PLUGIN_LICENSE_XXX) */
90 plugin_type_init init; /* function to invoke when plugin is loaded */
91 plugin_type_init deinit; /* function to invoke when plugin is unloaded */
92 struct st_mysql_show_var *status_vars;
93 struct st_mysql_sys_var **system_vars;
94 void *reserved1; /* reserved for dependency checking */
95};
9648
97extern char *opt_plugin_load;49extern char *opt_plugin_load;
98extern char *opt_plugin_dir_ptr;50extern char *opt_plugin_dir_ptr;
@@ -100,12 +52,12 @@
10052
101extern int plugin_init(int *argc, char **argv, int init_flags);53extern int plugin_init(int *argc, char **argv, int init_flags);
102extern void plugin_shutdown(void);54extern void plugin_shutdown(void);
103extern void my_print_help_inc_plugins(struct my_option *options, uint32_t size);55extern void my_print_help_inc_plugins(my_option *options);
104extern bool plugin_is_ready(const LEX_STRING *name, int type);56extern bool plugin_is_ready(const LEX_STRING *name, int type);
105extern bool mysql_install_plugin(Session *session, const LEX_STRING *name,57extern bool mysql_install_plugin(Session *session, const LEX_STRING *name,
106 const LEX_STRING *dl);58 const LEX_STRING *dl);
107extern bool mysql_uninstall_plugin(Session *session, const LEX_STRING *name);59extern bool mysql_uninstall_plugin(Session *session, const LEX_STRING *name);
108extern bool plugin_register_builtin(struct drizzled_plugin_manifest *plugin);60extern bool plugin_register_builtin(drizzled::plugin::Manifest *plugin);
109extern void plugin_sessionvar_init(Session *session);61extern void plugin_sessionvar_init(Session *session);
110extern void plugin_sessionvar_cleanup(Session *session);62extern void plugin_sessionvar_cleanup(Session *session);
111extern sys_var *intern_find_sys_var(const char *str, uint32_t, bool no_error);63extern sys_var *intern_find_sys_var(const char *str, uint32_t, bool no_error);
11264
=== modified file 'extra/clean_source.sh'
--- extra/clean_source.sh 2009-07-10 21:50:02 +0000
+++ extra/clean_source.sh 2009-07-15 21:16:34 +0000
@@ -15,8 +15,8 @@
15# along with this program; if not, write to the Free Software15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA16# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1717
18for file in `ack-grep -f | grep -v innobase | grep -v '\.pb\.'| grep -v bak-header | grep -v '^intl' | grep -v '^config' `; do18for file in `ack-grep -f | grep -v innobase | grep -v '\.pb\.'| grep -v bak-header | grep -v '^intl' | grep -v '^config' | grep -v '\.am$' | grep -v '\.ac$' | grep -v m4 | grep -v sql_yacc.yy | grep -v '.gperf$' `; do
19 grep Copyright $file >/dev/null 2>&1 || echo "No copyright header in $file"19 grep Copyright $file >/dev/null 2>&1 || echo "No copyright header in $file"
20 uncrustify -c ../config/uncrustify.cfg --replace $file20 uncrustify -c config/uncrustify.cfg --replace $file
21done21done
2222
2323
=== modified file 'm4/lib-prefix.m4'
--- m4/lib-prefix.m4 2009-07-14 22:35:09 +0000
+++ m4/lib-prefix.m4 2009-07-18 22:10:19 +0000
@@ -183,18 +183,13 @@
183 dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link."183 dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link."
184 dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the184 dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the
185 dnl symlink is missing, so we set acl_libdirstem2 too.185 dnl symlink is missing, so we set acl_libdirstem2 too.
186 AC_MSG_CHECKING([if buildling 64-bit app])186 AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit],
187 AC_RUN_IFELSE([187 [AC_RUN_IFELSE([
188 AC_LANG_PROGRAM([188 AC_LANG_PROGRAM([], [[
189 ], [189 return sizeof(void*) == 8 ? 0 : 1;
190 return sizeof(void*) == 8 ? 0 : 1;190 ]])
191 ]) 191 ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no])
192 ], [192 ])
193 gl_cv_solaris_64bit=yes
194 ], [
195 gl_cv_solaris_64bit=no
196 ])
197 AC_MSG_RESULT([$gl_cv_solaris_64bit])
198 if test $gl_cv_solaris_64bit = yes; then193 if test $gl_cv_solaris_64bit = yes; then
199 acl_libdirstem=lib/64194 acl_libdirstem=lib/64
200 case "$host_cpu" in195 case "$host_cpu" in
201196
=== modified file 'm4/pandora_64bit.m4'
--- m4/pandora_64bit.m4 2009-07-13 19:24:14 +0000
+++ m4/pandora_64bit.m4 2009-07-18 22:10:19 +0000
@@ -7,6 +7,8 @@
7dnl Macro: PANDORA_64BIT7dnl Macro: PANDORA_64BIT
8dnl ---------------------------------------------------------------------------8dnl ---------------------------------------------------------------------------
9AC_DEFUN([PANDORA_64BIT],[9AC_DEFUN([PANDORA_64BIT],[
10 AC_BEFORE([$0], [AC_LIB_PREFIX])
11
1012
11 AC_ARG_ENABLE([64bit],[13 AC_ARG_ENABLE([64bit],[
12 AS_HELP_STRING([--disable-64bit],14 AS_HELP_STRING([--disable-64bit],
1315
=== modified file 'm4/pandora_canonical.m4'
--- m4/pandora_canonical.m4 2009-07-15 19:22:16 +0000
+++ m4/pandora_canonical.m4 2009-07-18 22:10:19 +0000
@@ -4,7 +4,7 @@
4dnl with or without modifications, as long as this notice is preserved.4dnl with or without modifications, as long as this notice is preserved.
55
6dnl Which version of the canonical setup we're using6dnl Which version of the canonical setup we're using
7AC_DEFUN([PANDORA_CANONICAL_VERSION],[0.20])7AC_DEFUN([PANDORA_CANONICAL_VERSION],[0.22])
88
9AC_DEFUN([PANDORA_FORCE_DEPEND_TRACKING],[9AC_DEFUN([PANDORA_FORCE_DEPEND_TRACKING],[
10 dnl Force dependency tracking on for Sun Studio builds10 dnl Force dependency tracking on for Sun Studio builds
@@ -59,6 +59,7 @@
59 59
60 AC_REQUIRE([AC_PROG_CC])60 AC_REQUIRE([AC_PROG_CC])
61 AC_REQUIRE([PANDORA_MAC_GCC42])61 AC_REQUIRE([PANDORA_MAC_GCC42])
62 AC_REQUIRE([PANDORA_64BIT])
6263
63 dnl Once we can use a modern autoconf, we can use this64 dnl Once we can use a modern autoconf, we can use this
64 dnl AC_PROG_CC_C9965 dnl AC_PROG_CC_C99
@@ -66,6 +67,7 @@
66 AC_PROG_CPP67 AC_PROG_CPP
67 AM_PROG_CC_C_O68 AM_PROG_CC_C_O
6869
70
69 gl_USE_SYSTEM_EXTENSIONS71 gl_USE_SYSTEM_EXTENSIONS
70 m4_if(PCT_FORCE_GCC42, [yes], [72 m4_if(PCT_FORCE_GCC42, [yes], [
71 AS_IF([test "$GCC" = "yes"], PANDORA_ENSURE_GCC_VERSION)73 AS_IF([test "$GCC" = "yes"], PANDORA_ENSURE_GCC_VERSION)
@@ -111,7 +113,6 @@
111 PANDORA_CHECK_CXX_VERSION113 PANDORA_CHECK_CXX_VERSION
112114
113 PANDORA_OPTIMIZE115 PANDORA_OPTIMIZE
114 PANDORA_64BIT
115116
116 dnl We need to inject error into the cflags to test if visibility works or not117 dnl We need to inject error into the cflags to test if visibility works or not
117 save_CFLAGS="${CFLAGS}"118 save_CFLAGS="${CFLAGS}"
118119
=== modified file 'mysys/base64.cc'
--- mysys/base64.cc 2009-05-03 15:58:12 +0000
+++ mysys/base64.cc 2009-07-17 22:25:54 +0000
@@ -213,9 +213,9 @@
213 i++;213 i++;
214214
215 end:215 end:
216 b[0]= (c >> 16) & 0xff;216 b[0]= char((c >> 16) & 0xff);
217 b[1]= (c >> 8) & 0xff;217 b[1]= char((c >> 8) & 0xff);
218 b[2]= (c >> 0) & 0xff;218 b[2]= char((c >> 0) & 0xff);
219219
220 for (j=0; j<3-mark; j++)220 for (j=0; j<3-mark; j++)
221 *d++= b[j];221 *d++= b[j];
@@ -228,7 +228,7 @@
228 The variable 'i' is set to 'len' when padding has been read, so it228 The variable 'i' is set to 'len' when padding has been read, so it
229 does not actually reflect the number of bytes read from 'src'.229 does not actually reflect the number of bytes read from 'src'.
230 */230 */
231 return i != len ? -1 : d - dst_base;231 return (i != len) ? -1 : int(d - dst_base);
232}232}
233233
234234
235235
=== modified file 'mysys/checksum.cc'
--- mysys/checksum.cc 2009-04-17 21:01:47 +0000
+++ mysys/checksum.cc 2009-07-17 22:25:54 +0000
@@ -30,6 +30,6 @@
3030
31ha_checksum my_checksum(ha_checksum crc, const unsigned char *pos, size_t length)31ha_checksum my_checksum(ha_checksum crc, const unsigned char *pos, size_t length)
32{32{
33 return (ha_checksum)crc32((uint32_t)crc, pos, length);33 return ha_checksum(crc32((uint32_t)crc, pos, uInt(length)));
34}34}
3535
3636
=== modified file 'mysys/default.cc'
--- mysys/default.cc 2009-07-10 21:19:35 +0000
+++ mysys/default.cc 2009-07-17 23:20:36 +0000
@@ -164,7 +164,7 @@
164 /* Handle --defaults-group-suffix= */164 /* Handle --defaults-group-suffix= */
165 uint32_t i;165 uint32_t i;
166 const char **extra_groups;166 const char **extra_groups;
167 const uint32_t instance_len= strlen(my_defaults_group_suffix);167 const size_t instance_len= strlen(my_defaults_group_suffix);
168 struct handle_option_ctx *ctx= (struct handle_option_ctx*) func_ctx;168 struct handle_option_ctx *ctx= (struct handle_option_ctx*) func_ctx;
169 char *ptr;169 char *ptr;
170 TYPELIB *group= ctx->group;170 TYPELIB *group= ctx->group;
@@ -176,7 +176,7 @@
176176
177 for (i= 0; i < group->count; i++)177 for (i= 0; i < group->count; i++)
178 {178 {
179 uint32_t len;179 size_t len;
180 extra_groups[i]= group->type_names[i]; /** copy group */180 extra_groups[i]= group->type_names[i]; /** copy group */
181181
182 len= strlen(extra_groups[i]);182 len= strlen(extra_groups[i]);
@@ -455,8 +455,8 @@
455 memcpy(res+1+args.elements, *argv + 1, (*argc-1)*sizeof(char*));455 memcpy(res+1+args.elements, *argv + 1, (*argc-1)*sizeof(char*));
456 res[args.elements+ *argc]=0; /* last null */456 res[args.elements+ *argc]=0; /* last null */
457457
458 (*argc)+=args.elements;458 (*argc)+=int(args.elements);
459 *argv= (char**) res;459 *argv= static_cast<char**>(res);
460 *(MEM_ROOT*) ptr= alloc; /* Save alloc root for free */460 *(MEM_ROOT*) ptr= alloc; /* Save alloc root for free */
461 delete_dynamic(&args);461 delete_dynamic(&args);
462 if (found_print_defaults)462 if (found_print_defaults)
463463
=== removed file 'mysys/default_modify.cc'
--- mysys/default_modify.cc 2009-06-30 21:28:16 +0000
+++ mysys/default_modify.cc 1970-01-01 00:00:00 +0000
@@ -1,252 +0,0 @@
1/* Copyright (C) 2005 MySQL AB
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
6
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
11
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
15
16#include "mysys/mysys_priv.h"
17#include <mystrings/m_string.h>
18#include <mysys/my_dir.h>
19
20#include <stdio.h>
21#include <algorithm>
22
23using namespace std;
24
25#define BUFF_SIZE 1024
26#define RESERVE 1024 /* Extend buffer with this extent */
27
28#define NEWLINE "\n"
29#define NEWLINE_LEN 1
30
31static char *add_option(char *dst, const char *option_value,
32 const char *option, int remove_option);
33
34
35/*
36 Add/remove option to the option file section.
37
38 SYNOPSYS
39 modify_defaults_file()
40 file_location The location of configuration file to edit
41 option The name of the option to look for (can be NULL)
42 option value The value of the option we would like to set (can be NULL)
43 section_name The name of the section (must be NOT NULL)
44 remove_option This defines what we want to remove:
45 - MY_REMOVE_NONE -- nothing to remove;
46 - MY_REMOVE_OPTION -- remove the specified option;
47 - MY_REMOVE_SECTION -- remove the specified section;
48 IMPLEMENTATION
49 We open the option file first, then read the file line-by-line,
50 looking for the section we need. At the same time we put these lines
51 into a buffer. Then we look for the option within this section and
52 change/remove it. In the end we get a buffer with modified version of the
53 file. Then we write it to the file, truncate it if needed and close it.
54 Note that there is a small time gap, when the file is incomplete,
55 and this theoretically might introduce a problem.
56
57 RETURN
58 0 - ok
59 1 - some error has occured. Probably due to the lack of resourses
60 2 - cannot open the file
61*/
62
63int modify_defaults_file(const char *file_location, const char *option,
64 const char *option_value,
65 const char *section_name, int remove_option)
66{
67 FILE *cnf_file;
68 struct stat file_stat;
69 char linebuff[BUFF_SIZE], *src_ptr, *dst_ptr, *file_buffer;
70 size_t opt_len= 0, optval_len= 0, sect_len;
71 uint32_t nr_newlines= 0;
72 size_t buffer_size;
73 bool in_section= false, opt_applied= 0;
74 size_t reserve_extended;
75 uint32_t new_opt_len;
76 int reserve_occupied= 0;
77
78 if (!(cnf_file= fopen(file_location, "r+")))
79 return(2);
80
81 if (fstat(fileno(cnf_file), &file_stat))
82 goto malloc_err;
83
84 if (option && option_value)
85 {
86 opt_len= strlen(option);
87 optval_len= strlen(option_value);
88 }
89
90 new_opt_len= opt_len + 1 + optval_len + NEWLINE_LEN;
91
92 /* calculate the size of the buffer we need */
93 reserve_extended= (opt_len +
94 1 + /* For '=' char */
95 optval_len + /* Option value len */
96 NEWLINE_LEN + /* Space for newline */
97 RESERVE); /* Some additional space */
98
99 buffer_size= (size_t)max((uint64_t)file_stat.st_size + 1, (uint64_t)SIZE_MAX);
100
101 /*
102 Reserve space to read the contents of the file and some more
103 for the option we want to add.
104 */
105 if (!(file_buffer= (char*) malloc(max(buffer_size + reserve_extended,
106 (size_t)SIZE_MAX))))
107 goto malloc_err;
108
109 sect_len= strlen(section_name);
110
111 for (dst_ptr= file_buffer; fgets(linebuff, BUFF_SIZE, cnf_file); )
112 {
113 /* Skip over whitespaces */
114 for (src_ptr= linebuff; my_isspace(&my_charset_utf8_general_ci, *src_ptr);
115 src_ptr++)
116 {}
117
118 if (!*src_ptr) /* Empty line */
119 {
120 nr_newlines++;
121 continue;
122 }
123
124 /* correct the option (if requested) */
125 if (option && in_section && !strncmp(src_ptr, option, opt_len) &&
126 (*(src_ptr + opt_len) == '=' ||
127 my_isspace(&my_charset_utf8_general_ci, *(src_ptr + opt_len)) ||
128 *(src_ptr + opt_len) == '\0'))
129 {
130 char *old_src_ptr= src_ptr;
131 src_ptr= strchr(src_ptr+ opt_len, '\0'); /* Find the end of the line */
132
133 /* could be negative */
134 reserve_occupied+= (int) new_opt_len - (int) (src_ptr - old_src_ptr);
135 if (reserve_occupied >= (int) reserve_extended)
136 {
137 reserve_extended= (uint32_t) reserve_occupied + RESERVE;
138 if (!(file_buffer= (char*) realloc(file_buffer, buffer_size +
139 reserve_extended)))
140 goto malloc_err;
141 }
142 opt_applied= 1;
143 dst_ptr= add_option(dst_ptr, option_value, option, remove_option);
144 }
145 else
146 {
147 /*
148 If we are going to the new group and have an option to apply, do
149 it now. If we are removing a single option or the whole section
150 this will only trigger opt_applied flag.
151 */
152
153 if (in_section && !opt_applied && *src_ptr == '[')
154 {
155 dst_ptr= add_option(dst_ptr, option_value, option, remove_option);
156 opt_applied= 1; /* set the flag to do write() later */
157 reserve_occupied= new_opt_len+ opt_len + 1 + NEWLINE_LEN;
158 }
159
160 for (; nr_newlines; nr_newlines--)
161 dst_ptr= strcpy(dst_ptr, NEWLINE)+NEWLINE_LEN;
162
163 /* Skip the section if MY_REMOVE_SECTION was given */
164 if (!in_section || remove_option != MY_REMOVE_SECTION)
165 dst_ptr= strcpy(dst_ptr, linebuff);
166 dst_ptr+= strlen(linebuff);
167 }
168 /* Look for a section */
169 if (*src_ptr == '[')
170 {
171 /* Copy the line to the buffer */
172 if (!strncmp(++src_ptr, section_name, sect_len))
173 {
174 src_ptr+= sect_len;
175 /* Skip over whitespaces. They are allowed after section name */
176 for (; my_isspace(&my_charset_utf8_general_ci, *src_ptr); src_ptr++)
177 {}
178
179 if (*src_ptr != ']')
180 {
181 in_section= false;
182 continue; /* Missing closing parenthesis. Assume this was no group */
183 }
184
185 if (remove_option == MY_REMOVE_SECTION)
186 dst_ptr= dst_ptr - strlen(linebuff);
187
188 in_section= true;
189 }
190 else
191 in_section= false; /* mark that this section is of no interest to us */
192 }
193 }
194
195 /*
196 File ended. Apply an option or set opt_applied flag (in case of
197 MY_REMOVE_SECTION) so that the changes are saved. Do not do anything
198 if we are removing non-existent option.
199 */
200
201 if (!opt_applied && in_section && (remove_option != MY_REMOVE_OPTION))
202 {
203 /* New option still remains to apply at the end */
204 if (!remove_option && *(dst_ptr - 1) != '\n')
205 dst_ptr= strcpy(dst_ptr, NEWLINE)+NEWLINE_LEN;
206 dst_ptr= add_option(dst_ptr, option_value, option, remove_option);
207 opt_applied= 1;
208 }
209 for (; nr_newlines; nr_newlines--)
210 dst_ptr= strcpy(dst_ptr, NEWLINE)+NEWLINE_LEN;
211
212 if (opt_applied)
213 {
214 /* Don't write the file if there are no changes to be made */
215 if (ftruncate(fileno(cnf_file), (size_t) (dst_ptr - file_buffer)) ||
216 fseeko(cnf_file, 0, SEEK_SET) ||
217 fwrite(file_buffer, 1, (size_t) (dst_ptr - file_buffer), cnf_file))
218 goto err;
219 }
220 if (fclose(cnf_file))
221 return(1);
222
223 free(file_buffer);
224 return(0);
225
226err:
227 free(file_buffer);
228malloc_err:
229 fclose(cnf_file);
230
231 return 1; /* out of resources */
232}
233
234
235static char *add_option(char *dst, const char *option_value,
236 const char *option, int remove_option)
237{
238 if (!remove_option)
239 {
240 dst= strcpy(dst, option);
241 dst+= strlen(option);
242 if (*option_value)
243 {
244 *dst++= '=';
245 dst= strcpy(dst, option_value);
246 dst+= strlen(option_value);
247 }
248 /* add a newline */
249 dst= strcpy(dst, NEWLINE)+NEWLINE_LEN;
250 }
251 return dst;
252}
2530
=== modified file 'mysys/my_bitmap.h'
--- mysys/my_bitmap.h 2009-05-23 00:05:52 +0000
+++ mysys/my_bitmap.h 2009-07-17 22:25:54 +0000
@@ -80,7 +80,7 @@
8080
81static inline void bitmap_set_bit(MY_BITMAP const *map, uint32_t bit)81static inline void bitmap_set_bit(MY_BITMAP const *map, uint32_t bit)
82{82{
83 ((unsigned char *)map->bitmap)[bit / 8] |= (1 << ((bit) & 7));83 ((unsigned char *)map->bitmap)[bit / 8] |= (unsigned char)(1 << ((bit) & 7));
84}84}
8585
86static inline void bitmap_flip_bit(MY_BITMAP const *map, uint32_t bit)86static inline void bitmap_flip_bit(MY_BITMAP const *map, uint32_t bit)
8787
=== modified file 'mysys/my_sys.h'
--- mysys/my_sys.h 2009-07-11 06:24:19 +0000
+++ mysys/my_sys.h 2009-07-17 23:20:36 +0000
@@ -71,10 +71,6 @@
71#define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */71#define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */
72#define MY_GIVE_INFO 2 /* Give time info about process*/72#define MY_GIVE_INFO 2 /* Give time info about process*/
7373
74#define MY_REMOVE_NONE 0 /* Params for modify_defaults_file */
75#define MY_REMOVE_OPTION 1
76#define MY_REMOVE_SECTION 2
77
78#define ME_HIGHBYTE 8 /* Shift for colours */74#define ME_HIGHBYTE 8 /* Shift for colours */
79#define ME_NOCUR 1 /* Don't use curses message */75#define ME_NOCUR 1 /* Don't use curses message */
80#define ME_OLDWIN 2 /* Use old window */76#define ME_OLDWIN 2 /* Use old window */
@@ -401,9 +397,6 @@
401 char **group_suffix);397 char **group_suffix);
402extern int load_defaults(const char *conf_file, const char **groups,398extern int load_defaults(const char *conf_file, const char **groups,
403 int *argc, char ***argv);399 int *argc, char ***argv);
404extern int modify_defaults_file(const char *file_location, const char *option,
405 const char *option_value,
406 const char *section_name, int remove_option);
407extern int my_search_option_files(const char *conf_file, int *argc,400extern int my_search_option_files(const char *conf_file, int *argc,
408 char ***argv, uint32_t *args_used,401 char ***argv, uint32_t *args_used,
409 Process_option_func func, void *func_ctx);402 Process_option_func func, void *func_ctx);
410403
=== modified file 'plugin/info_schema/info_schema_methods.cc'
--- plugin/info_schema/info_schema_methods.cc 2009-07-09 01:35:10 +0000
+++ plugin/info_schema/info_schema_methods.cc 2009-07-18 18:11:42 +0000
@@ -330,7 +330,7 @@
330 return (0);330 return (0);
331}331}
332332
333class ShowPlugins : public unary_function<st_plugin_int *, bool>333class ShowPlugins : public unary_function<drizzled::plugin::Handle *, bool>
334{334{
335 Session *session;335 Session *session;
336 Table *table;336 Table *table;
@@ -340,17 +340,17 @@
340340
341 result_type operator() (argument_type plugin)341 result_type operator() (argument_type plugin)
342 {342 {
343 struct drizzled_plugin_manifest *plug= plugin_decl(plugin);343 const drizzled::plugin::Manifest &manifest= plugin->getManifest();
344 const CHARSET_INFO * const cs= system_charset_info;344 const CHARSET_INFO * const cs= system_charset_info;
345345
346 table->restoreRecordAsDefault();346 table->restoreRecordAsDefault();
347347
348 table->field[0]->store(plugin_name(plugin)->str,348 table->field[0]->store(plugin->getName().c_str(),
349 plugin_name(plugin)->length, cs);349 plugin->getName().size(), cs);
350350
351 if (plug->version)351 if (manifest.version)
352 {352 {
353 table->field[1]->store(plug->version, strlen(plug->version), cs);353 table->field[1]->store(manifest.version, strlen(manifest.version), cs);
354 table->field[1]->set_notnull();354 table->field[1]->set_notnull();
355 }355 }
356 else356 else
@@ -365,9 +365,9 @@
365 table->field[2]->store(STRING_WITH_LEN("INACTIVE"), cs);365 table->field[2]->store(STRING_WITH_LEN("INACTIVE"), cs);
366 }366 }
367367
368 if (plug->author)368 if (manifest.author)
369 {369 {
370 table->field[3]->store(plug->author, strlen(plug->author), cs);370 table->field[3]->store(manifest.author, strlen(manifest.author), cs);
371 table->field[3]->set_notnull();371 table->field[3]->set_notnull();
372 }372 }
373 else373 else
@@ -375,9 +375,9 @@
375 table->field[3]->set_null();375 table->field[3]->set_null();
376 }376 }
377377
378 if (plug->descr)378 if (manifest.descr)
379 {379 {
380 table->field[4]->store(plug->descr, strlen(plug->descr), cs);380 table->field[4]->store(manifest.descr, strlen(manifest.descr), cs);
381 table->field[4]->set_notnull();381 table->field[4]->set_notnull();
382 }382 }
383 else383 else
@@ -385,22 +385,23 @@
385 table->field[4]->set_null();385 table->field[4]->set_null();
386 }386 }
387387
388 switch (plug->license) {388 switch (manifest.license) {
389 case PLUGIN_LICENSE_GPL:389 case PLUGIN_LICENSE_GPL:
390 table->field[5]->store(PLUGIN_LICENSE_GPL_STRING,390 table->field[5]->store(drizzled::plugin::LICENSE_GPL_STRING.c_str(),
391 strlen(PLUGIN_LICENSE_GPL_STRING), cs);391 drizzled::plugin::LICENSE_GPL_STRING.size(), cs);
392 break;392 break;
393 case PLUGIN_LICENSE_BSD:393 case PLUGIN_LICENSE_BSD:
394 table->field[5]->store(PLUGIN_LICENSE_BSD_STRING,394 table->field[5]->store(drizzled::plugin::LICENSE_BSD_STRING.c_str(),
395 strlen(PLUGIN_LICENSE_BSD_STRING), cs);395 drizzled::plugin::LICENSE_BSD_STRING.size(), cs);
396 break;396 break;
397 case PLUGIN_LICENSE_LGPL:397 case PLUGIN_LICENSE_LGPL:
398 table->field[5]->store(PLUGIN_LICENSE_LGPL_STRING,398 table->field[5]->store(drizzled::plugin::LICENSE_LGPL_STRING.c_str(),
399 strlen(PLUGIN_LICENSE_LGPL_STRING), cs);399 drizzled::plugin::LICENSE_LGPL_STRING.size(), cs);
400 break;400 break;
401 default:401 default:
402 table->field[5]->store(PLUGIN_LICENSE_PROPRIETARY_STRING,402 table->field[5]->store(drizzled::plugin::LICENSE_PROPRIETARY_STRING.c_str(),
403 strlen(PLUGIN_LICENSE_PROPRIETARY_STRING), cs);403 drizzled::plugin::LICENSE_PROPRIETARY_STRING.size(),
404 cs);
404 break;405 break;
405 }406 }
406 table->field[5]->set_notnull();407 table->field[5]->set_notnull();
@@ -414,8 +415,8 @@
414 Table *table= tables->table;415 Table *table= tables->table;
415416
416 PluginRegistry &registry= PluginRegistry::getPluginRegistry();417 PluginRegistry &registry= PluginRegistry::getPluginRegistry();
417 vector<st_plugin_int *> plugins= registry.get_list(true);418 vector<drizzled::plugin::Handle *> plugins= registry.get_list(true);
418 vector<st_plugin_int *>::iterator iter=419 vector<drizzled::plugin::Handle *>::iterator iter=
419 find_if(plugins.begin(), plugins.end(), ShowPlugins(session, table));420 find_if(plugins.begin(), plugins.end(), ShowPlugins(session, table));
420 if (iter != plugins.end())421 if (iter != plugins.end())
421 {422 {
422423
=== modified file 'plugin/innobase/handler/ha_innodb.cc'
--- plugin/innobase/handler/ha_innodb.cc 2009-07-07 09:06:29 +0000
+++ plugin/innobase/handler/ha_innodb.cc 2009-07-15 21:00:16 +0000
@@ -131,7 +131,7 @@
131#ifdef DRIZZLE_DYNAMIC_PLUGIN131#ifdef DRIZZLE_DYNAMIC_PLUGIN
132/* These must be weak global variables in the dynamic plugin. */132/* These must be weak global variables in the dynamic plugin. */
133#ifdef __WIN__133#ifdef __WIN__
134struct drizzled_plugin_manifest* builtin_innobase_plugin_ptr;134struct drizzled::plugin::Manifest* builtin_innobase_plugin_ptr;
135#else135#else
136int builtin_innobase_plugin;136int builtin_innobase_plugin;
137#endif /* __WIN__ */137#endif /* __WIN__ */
@@ -9063,9 +9063,9 @@
90639063
9064 /* Copy the system variables. */9064 /* Copy the system variables. */
90659065
9066 struct drizzled_plugin_manifest* builtin;9066 drizzled::plugin::Manifest* builtin;
9067 struct st_mysql_sys_var** sta; /* static parameters */9067 st_mysql_sys_var** sta; /* static parameters */
9068 struct st_mysql_sys_var** dyn; /* dynamic parameters */9068 st_mysql_sys_var** dyn; /* dynamic parameters */
90699069
9070#ifdef __WIN__9070#ifdef __WIN__
9071 if (!builtin_innobase_plugin_ptr) {9071 if (!builtin_innobase_plugin_ptr) {
@@ -9076,7 +9076,7 @@
9076 builtin = builtin_innobase_plugin_ptr;9076 builtin = builtin_innobase_plugin_ptr;
9077#else9077#else
90789078
9079 builtin = (struct drizzled_plugin_manifest*) &builtin_innobase_plugin;9079 builtin = (drizzled::plugin::Manifest*) &builtin_innobase_plugin;
9080#endif9080#endif
90819081
9082 for (sta = builtin->system_vars; *sta != NULL; sta++) {9082 for (sta = builtin->system_vars; *sta != NULL; sta++) {
90839083
=== modified file 'plugin/innobase/handler/win_delay_loader.cc'
--- plugin/innobase/handler/win_delay_loader.cc 2009-04-11 00:30:51 +0000
+++ plugin/innobase/handler/win_delay_loader.cc 2009-07-15 21:00:16 +0000
@@ -76,7 +76,7 @@
76The following is defined in ha_innodb.cc. It is used for copying the76The following is defined in ha_innodb.cc. It is used for copying the
77system variables from the builtin innodb plugin to the dynamic plugin.77system variables from the builtin innodb plugin to the dynamic plugin.
78*/78*/
79extern struct drizzled_plugin_manifest* builtin_innobase_plugin_ptr;79extern drizzled::plugin::Manifest* builtin_innobase_plugin_ptr;
8080
81/***********************************************************************81/***********************************************************************
82The preffered load-address defined in PE (portable executable format).*/82The preffered load-address defined in PE (portable executable format).*/
@@ -644,7 +644,7 @@
644 wdl_binlog_format_names, char*);644 wdl_binlog_format_names, char*);
645645
646 /* It is fine if builtin_innobase_plugin is not available. */646 /* It is fine if builtin_innobase_plugin is not available. */
647 builtin_innobase_plugin_ptr = (struct drizzled_plugin_manifest*)647 builtin_innobase_plugin_ptr = (drizzled::plugin::Manifest*)
648 wdl_get_varaddr_from_map(648 wdl_get_varaddr_from_map(
649 hmod,649 hmod,
650 "?builtin_innobase_plugin@@3PAUdrizzled_plugin_manifest@@A");650 "?builtin_innobase_plugin@@3PAUdrizzled_plugin_manifest@@A");