~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_plugin.cc

MergedĀ inĀ latest.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
#include <drizzled/server_includes.h>
17
17
#include <mysys/my_getopt.h>
18
18
 
19
 
#include <authentication.h>
20
 
#include <logging.h>
21
 
#include <errmsg.h>
22
 
#include <configvar.h>
23
 
#include <qcache.h>
24
 
 
25
 
#include <drizzled/drizzled_error_messages.h>
 
19
#include <drizzled/authentication.h>
 
20
#include <drizzled/logging.h>
 
21
#include <drizzled/errmsg.h>
 
22
#include <drizzled/configvar.h>
 
23
#include <drizzled/qcache.h>
 
24
#include <drizzled/parser.h>
 
25
#include <drizzled/scheduling.h>
 
26
 
 
27
#include <string>
 
28
 
 
29
#include <drizzled/error.h>
 
30
#include <drizzled/gettext.h>
26
31
 
27
32
#define REPORT_TO_LOG  1
28
33
#define REPORT_TO_USER 2
30
35
#define plugin_ref_to_int(A) (A ? A[0] : NULL)
31
36
#define plugin_int_to_ref(A) &(A)
32
37
 
 
38
using namespace std;
 
39
 
33
40
extern struct st_mysql_plugin *mysqld_builtins[];
34
41
 
35
42
char *opt_plugin_load= NULL;
51
58
  { C_STRING_WITH_LEN("ERRMSG") },
52
59
  { C_STRING_WITH_LEN("AUTH") },
53
60
  { C_STRING_WITH_LEN("CONFIGVAR") },
54
 
  { C_STRING_WITH_LEN("QCACHE") }
 
61
  { C_STRING_WITH_LEN("QCACHE") },
 
62
  { C_STRING_WITH_LEN("PARSER") },
 
63
  { C_STRING_WITH_LEN("SCHEDULING") }
55
64
};
56
65
 
57
66
extern int initialize_schema_table(st_plugin_int *plugin);
77
86
  errmsg_initializer,  /* Error Messages */
78
87
  authentication_initializer,  /* Auth */
79
88
  configvar_initializer,
80
 
  qcache_initializer
 
89
  qcache_initializer,
 
90
  parser_initializer,
 
91
  scheduling_initializer
81
92
};
82
93
 
83
94
plugin_type_init plugin_type_deinitialize[DRIZZLE_MAX_PLUGIN_TYPE_NUM]=
92
103
  errmsg_finalizer,  /* Logger */
93
104
  authentication_finalizer,  /* Auth */
94
105
  configvar_finalizer,
95
 
  qcache_finalizer
 
106
  qcache_finalizer,
 
107
  parser_finalizer,
 
108
  scheduling_finalizer
96
109
};
97
110
 
98
111
static const char *plugin_declarations_sym= "_mysql_plugin_declarations_";
324
337
 
325
338
static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report)
326
339
{
327
 
  char dlpath[FN_REFLEN];
328
 
  uint32_t plugin_dir_len, dummy_errors, dlpathlen;
 
340
  string dlpath;
 
341
  uint32_t plugin_dir_len, dummy_errors;
329
342
  struct st_plugin_dl *tmp, plugin_dl;
330
343
  void *sym;
331
344
  plugin_dir_len= strlen(opt_plugin_dir);
 
345
  dlpath.reserve(FN_REFLEN);
332
346
  /*
333
347
    Ensure that the dll doesn't have a path.
334
348
    This is done to ensure that only approved libraries from the
353
367
  }
354
368
  memset(&plugin_dl, 0, sizeof(plugin_dl));
355
369
  /* Compile dll path */
356
 
  dlpathlen=
357
 
    strxnmov(dlpath, sizeof(dlpath) - 1, opt_plugin_dir, "/", dl->str, NULL) -
358
 
    dlpath;
 
370
  dlpath.append(opt_plugin_dir);
 
371
  dlpath.append("/");
 
372
  dlpath.append(dl->str);
359
373
  plugin_dl.ref_count= 1;
360
374
  /* Open new dll handle */
361
 
  if (!(plugin_dl.handle= dlopen(dlpath, RTLD_LAZY|RTLD_GLOBAL)))
 
375
  if (!(plugin_dl.handle= dlopen(dlpath.c_str(), RTLD_LAZY|RTLD_GLOBAL)))
362
376
  {
363
377
    const char *errmsg=dlerror();
364
 
    if (!strncmp(dlpath, errmsg, dlpathlen))
 
378
    uint32_t dlpathlen= dlpath.length();
 
379
    if (!dlpath.compare(0, dlpathlen, errmsg))
365
380
    { // if errmsg starts from dlpath, trim this prefix.
366
381
      errmsg+=dlpathlen;
367
382
      if (*errmsg == ':') errmsg++;
368
383
      if (*errmsg == ' ') errmsg++;
369
384
    }
370
385
    if (report & REPORT_TO_USER)
371
 
      my_error(ER_CANT_OPEN_LIBRARY, MYF(0), dlpath, errno, errmsg);
 
386
      my_error(ER_CANT_OPEN_LIBRARY, MYF(0), dlpath.c_str(), errno, errmsg);
372
387
    if (report & REPORT_TO_LOG)
373
 
      sql_print_error(ER(ER_CANT_OPEN_LIBRARY), dlpath, errno, errmsg);
 
388
      sql_print_error(ER(ER_CANT_OPEN_LIBRARY), dlpath.c_str(), errno, errmsg);
374
389
    return(0);
375
390
  }
376
391
 
591
606
  for (plugin= tmp.plugin_dl->plugins; plugin->name; plugin++)
592
607
  {
593
608
    uint32_t name_len= strlen(plugin->name);
594
 
    if (plugin->type >= 0 && plugin->type < DRIZZLE_MAX_PLUGIN_TYPE_NUM &&
 
609
    if (plugin->type < DRIZZLE_MAX_PLUGIN_TYPE_NUM &&
595
610
        ! my_strnncoll(system_charset_info,
596
611
                       (const unsigned char *)name->str, name->length,
597
612
                       (const unsigned char *)plugin->name,