81
static const char *plugin_interface_version_sym=
82
"_mysql_plugin_interface_version_";
83
static const char *sizeof_st_plugin_sym=
84
"_mysql_sizeof_struct_st_plugin_";
85
81
static const char *plugin_declarations_sym= "_mysql_plugin_declarations_";
86
static int min_plugin_interface_version= MYSQL_PLUGIN_INTERFACE_VERSION & ~0xFF;
88
83
/* Note that 'int version' must be the first field of every plugin
89
84
sub-structure (plugin->info).
91
static int min_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]=
93
MYSQL_UDF_INTERFACE_VERSION,
94
MYSQL_UDA_INTERFACE_VERSION,
95
MYSQL_HANDLERTON_INTERFACE_VERSION,
96
MYSQL_DAEMON_INTERFACE_VERSION,
97
MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION,
98
MYSQL_AUDIT_INTERFACE_VERSION,
99
MYSQL_LOG_INTERFACE_VERSION,
100
MYSQL_AUTH_INTERFACE_VERSION
102
static int cur_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]=
104
MYSQL_UDF_INTERFACE_VERSION,
105
MYSQL_UDA_INTERFACE_VERSION,
106
MYSQL_HANDLERTON_INTERFACE_VERSION,
107
MYSQL_DAEMON_INTERFACE_VERSION,
108
MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION,
109
MYSQL_AUDIT_INTERFACE_VERSION,
110
MYSQL_LOG_INTERFACE_VERSION,
111
MYSQL_AUTH_INTERFACE_VERSION
114
87
static bool initialized= 0;
385
356
sql_print_error(ER(ER_CANT_OPEN_LIBRARY), dlpath, errno, errmsg);
388
/* Determine interface version */
389
if (!(sym= dlsym(plugin_dl.handle, plugin_interface_version_sym)))
391
free_plugin_mem(&plugin_dl);
392
if (report & REPORT_TO_USER)
393
my_error(ER_CANT_FIND_DL_ENTRY, MYF(0), plugin_interface_version_sym);
394
if (report & REPORT_TO_LOG)
395
sql_print_error(ER(ER_CANT_FIND_DL_ENTRY), plugin_interface_version_sym);
398
plugin_dl.version= *(int *)sym;
400
if (plugin_dl.version < min_plugin_interface_version ||
401
(plugin_dl.version >> 8) > (MYSQL_PLUGIN_INTERFACE_VERSION >> 8))
403
free_plugin_mem(&plugin_dl);
404
if (report & REPORT_TO_USER)
405
my_error(ER_CANT_OPEN_LIBRARY, MYF(0), dlpath, 0,
406
"plugin interface version mismatch");
407
if (report & REPORT_TO_LOG)
408
sql_print_error(ER(ER_CANT_OPEN_LIBRARY), dlpath, 0,
409
"plugin interface version mismatch");
412
360
/* Find plugin declarations */
413
361
if (!(sym= dlsym(plugin_dl.handle, plugin_declarations_sym)))
423
if (plugin_dl.version != MYSQL_PLUGIN_INTERFACE_VERSION)
426
uint sizeof_st_plugin;
427
struct st_mysql_plugin *old, *cur;
428
char *ptr= (char *)sym;
430
if ((sym= dlsym(plugin_dl.handle, sizeof_st_plugin_sym)))
431
sizeof_st_plugin= *(int *)sym;
434
#ifdef ERROR_ON_NO_SIZEOF_PLUGIN_SYMBOL
435
free_plugin_mem(&plugin_dl);
436
if (report & REPORT_TO_USER)
437
my_error(ER_CANT_FIND_DL_ENTRY, MYF(0), sizeof_st_plugin_sym);
438
if (report & REPORT_TO_LOG)
439
sql_print_error(ER(ER_CANT_FIND_DL_ENTRY), sizeof_st_plugin_sym);
443
When the following assert starts failing, we'll have to switch
444
to the upper branch of the #ifdef
446
assert(min_plugin_interface_version == 0);
447
sizeof_st_plugin= (int)offsetof(struct st_mysql_plugin, version);
452
((struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
456
cur= (struct st_mysql_plugin*)
457
my_malloc(i*sizeof(struct st_mysql_plugin), MYF(MY_ZEROFILL|MY_WME));
460
free_plugin_mem(&plugin_dl);
461
if (report & REPORT_TO_USER)
462
my_error(ER_OUTOFMEMORY, MYF(0), plugin_dl.dl.length);
463
if (report & REPORT_TO_LOG)
464
sql_print_error(ER(ER_OUTOFMEMORY), plugin_dl.dl.length);
468
All st_plugin fields not initialized in the plugin explicitly, are
469
set to 0. It matches C standard behaviour for struct initializers that
470
have less values than the struct definition.
473
(old=(struct st_mysql_plugin *)(ptr+i*sizeof_st_plugin))->info;
475
memcpy(cur+i, old, min(sizeof(cur[i]), sizeof_st_plugin));
479
371
plugin_dl.plugins= (struct st_mysql_plugin *)sym;
481
373
/* Duplicate and convert dll name */
679
571
if (! (tmp.plugin_dl= plugin_dl_add(dl, report)))
681
573
/* Find plugin by name */
682
for (plugin= tmp.plugin_dl->plugins; plugin->info; plugin++)
574
for (plugin= tmp.plugin_dl->plugins; plugin->name; plugin++)
684
576
uint name_len= strlen(plugin->name);
685
577
if (plugin->type >= 0 && plugin->type < MYSQL_MAX_PLUGIN_TYPE_NUM &&
691
583
struct st_plugin_int *tmp_plugin_ptr;
692
if (*(int*)plugin->info <
693
min_plugin_info_interface_version[plugin->type] ||
694
((*(int*)plugin->info) >> 8) >
695
(cur_plugin_info_interface_version[plugin->type] >> 8))
698
strxnmov(buf, sizeof(buf) - 1, "API version for ",
699
plugin_type_names[plugin->type].str,
700
" plugin is too different", NullS);
701
if (report & REPORT_TO_USER)
702
my_error(ER_CANT_OPEN_LIBRARY, MYF(0), dl->str, 0, buf);
703
if (report & REPORT_TO_LOG)
704
sql_print_error(ER(ER_CANT_OPEN_LIBRARY), dl->str, 0, buf);
707
585
tmp.plugin= plugin;
708
586
tmp.name.str= (char *)plugin->name;
709
587
tmp.name.length= name_len;
1028
906
for (builtins= mysqld_builtins; *builtins; builtins++)
1030
for (plugin= *builtins; plugin->info; plugin++)
908
for (plugin= *builtins; plugin->name; plugin++)
1032
910
bzero(&tmp, sizeof(tmp));
1033
911
tmp.plugin= plugin;
1176
1054
if ((plugin_dl= plugin_dl_add(&dl, REPORT_TO_LOG)))
1178
for (plugin= plugin_dl->plugins; plugin->info; plugin++)
1056
for (plugin= plugin_dl->plugins; plugin->name; plugin++)
1180
1058
name.str= (char *) plugin->name;
1181
1059
name.length= strlen(name.str);