~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/module/loader.cc

  • Committer: Brian Aker
  • Date: 2011-02-22 06:12:02 UTC
  • mfrom: (2190.1.6 drizzle-build)
  • Revision ID: brian@tangent.org-20110222061202-k03czxykqy4x9hjs
List update, header fixes, multiple symbols, and David deletes some code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
   along with this program; if not, write to the Free Software
14
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
 
#include "config.h"
 
16
#include <config.h>
17
17
 
18
18
#include <dlfcn.h>
19
19
 
26
26
 
27
27
#include <boost/program_options.hpp>
28
28
 
29
 
#include "drizzled/option.h"
30
 
#include "drizzled/internal/m_string.h"
 
29
#include <drizzled/option.h>
 
30
#include <drizzled/internal/m_string.h>
31
31
 
32
 
#include "drizzled/plugin.h"
33
 
#include "drizzled/module/load_list.h"
34
 
#include "drizzled/module/library.h"
35
 
#include "drizzled/module/registry.h"
36
 
#include "drizzled/module/option_context.h"
37
 
#include "drizzled/sql_parse.h"
38
 
#include "drizzled/show.h"
39
 
#include "drizzled/cursor.h"
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"
45
 
#include "drizzled/errmsg_print.h"
46
 
#include "drizzled/strfunc.h"
47
 
#include "drizzled/pthread_globals.h"
48
 
#include "drizzled/util/tokenize.h"
 
32
#include <drizzled/plugin.h>
 
33
#include <drizzled/module/load_list.h>
 
34
#include <drizzled/module/library.h>
 
35
#include <drizzled/module/registry.h>
 
36
#include <drizzled/module/option_context.h>
 
37
#include <drizzled/sql_parse.h>
 
38
#include <drizzled/show.h>
 
39
#include <drizzled/cursor.h>
 
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>
 
45
#include <drizzled/errmsg_print.h>
 
46
#include <drizzled/strfunc.h>
 
47
#include <drizzled/pthread_globals.h>
 
48
#include <drizzled/util/tokenize.h>
49
49
 
50
50
#include <boost/foreach.hpp>
51
51
 
141
141
static void unlock_variables(Session *session, drizzle_system_variables *vars);
142
142
static void cleanup_variables(drizzle_system_variables *vars);
143
143
 
144
 
/* declared in set_var.cc */
145
 
extern sys_var *intern_find_sys_var(const char *str, uint32_t length, bool no_error);
146
 
 
147
144
 
148
145
/****************************************************************************
149
146
  Plugin support code
165
162
 
166
163
  if (registry.find(library->getName()))
167
164
  {
168
 
    errmsg_printf(ERRMSG_LVL_WARN, ER(ER_PLUGIN_EXISTS),
 
165
    errmsg_printf(error::WARN, ER(ER_PLUGIN_EXISTS),
169
166
                  library->getName().c_str());
170
167
    return false;
171
168
  }
176
173
 
177
174
  if (registry.find(manifest->name))
178
175
  {
179
 
    errmsg_printf(ERRMSG_LVL_ERROR, 
 
176
    errmsg_printf(error::ERROR, 
180
177
                  _("Plugin '%s' contains the name '%s' in its manifest, which "
181
178
                    "has already been registered.\n"),
182
179
                  library->getName().c_str(),
193
190
    registry.add(tmp);
194
191
    return false;
195
192
  }
196
 
  errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_CANT_FIND_DL_ENTRY),
 
193
  errmsg_printf(error::ERROR, ER(ER_CANT_FIND_DL_ENTRY),
197
194
                library->getName().c_str());
198
195
  return true;
199
196
}
223
220
  {
224
221
    if (module->getManifest().init(loading_context))
225
222
    {
226
 
      errmsg_printf(ERRMSG_LVL_ERROR,
 
223
      errmsg_printf(error::ERROR,
227
224
                    _("Plugin '%s' init function returned error.\n"),
228
225
                    module->getName().c_str());
229
226
      return true;
373
370
  /*
374
371
    Now we initialize all remaining plugins
375
372
  */
376
 
  std::map<std::string, module::Module *>::const_iterator modules=
377
 
    registry.getModulesMap().begin();
 
373
  module::Registry::ModuleList module_list= registry.getList();
 
374
  module::Registry::ModuleList::iterator modules= module_list.begin();
378
375
    
379
 
  while (modules != registry.getModulesMap().end())
 
376
  while (modules != module_list.end())
380
377
  {
381
 
    module::Module *module= (*modules).second;
 
378
    module::Module *module= *modules;
382
379
    ++modules;
383
380
    if (module->isInited == false)
384
381
    {
391
388
    }
392
389
  }
393
390
 
 
391
 
394
392
  BOOST_FOREACH(plugin::Plugin::map::value_type value, registry.getPluginsMap())
395
393
  {
396
394
    value.second->prime();
399
397
  return false;
400
398
}
401
399
 
 
400
/*
 
401
  Window of opportunity for plugins to issue any queries with the database up and running but with no user's connected.
 
402
*/
 
403
void plugin_startup_window(module::Registry &registry, drizzled::Session &session)
 
404
{
 
405
  BOOST_FOREACH(plugin::Plugin::map::value_type value, registry.getPluginsMap())
 
406
  {
 
407
    value.second->startup(session);
 
408
  }
 
409
}
 
410
 
402
411
class PrunePlugin :
403
412
  public unary_function<string, bool>
404
413
{
450
459
    library= registry.addLibrary(plugin_name, builtin);
451
460
    if (library == NULL)
452
461
    {
453
 
      errmsg_printf(ERRMSG_LVL_ERROR,
 
462
      errmsg_printf(error::ERROR,
454
463
                    _("Couldn't load plugin library named '%s'.\n"),
455
464
                    plugin_name.c_str());
456
465
      return true;
460
469
    if (plugin_add(registry, tmp_root, library, long_options))
461
470
    {
462
471
      registry.removeLibrary(plugin_name);
463
 
      errmsg_printf(ERRMSG_LVL_ERROR,
 
472
      errmsg_printf(error::ERROR,
464
473
                    _("Couldn't load plugin named '%s'.\n"),
465
474
                    plugin_name.c_str());
466
475
      return true;
500
509
****************************************************************************/
501
510
 
502
511
 
503
 
sys_var *find_sys_var(const char *str, uint32_t length)
504
 
{
505
 
  return intern_find_sys_var(str, length, false);
506
 
}
507
 
 
508
512
 
509
513
void plugin_sessionvar_init(Session *session)
510
514
{