16
16
#include <drizzled/server_includes.h>
17
17
#include <mysys/my_getopt.h>
19
#include <authentication.h>
22
#include <configvar.h>
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>
29
#include <drizzled/error.h>
30
#include <drizzled/gettext.h>
27
32
#define REPORT_TO_LOG 1
28
33
#define REPORT_TO_USER 2
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") }
57
66
extern int initialize_schema_table(st_plugin_int *plugin);
325
338
static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report)
327
char dlpath[FN_REFLEN];
328
uint32_t plugin_dir_len, dummy_errors, dlpathlen;
341
uint32_t plugin_dir_len, dummy_errors;
329
342
struct st_plugin_dl *tmp, plugin_dl;
331
344
plugin_dir_len= strlen(opt_plugin_dir);
345
dlpath.reserve(FN_REFLEN);
333
347
Ensure that the dll doesn't have a path.
334
348
This is done to ensure that only approved libraries from the
354
368
memset(&plugin_dl, 0, sizeof(plugin_dl));
355
369
/* Compile dll path */
357
strxnmov(dlpath, sizeof(dlpath) - 1, opt_plugin_dir, "/", dl->str, NULL) -
370
dlpath.append(opt_plugin_dir);
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)))
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++;
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);
591
606
for (plugin= tmp.plugin_dl->plugins; plugin->name; plugin++)
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,