MCPcopy Create free account
hub / github.com/MariaDB/server / read_mysql_plugin_info

Function read_mysql_plugin_info

sql/sql_plugin.cc:541–642  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

539
540#ifdef HAVE_DLOPEN
541static my_bool read_mysql_plugin_info(struct st_plugin_dl *plugin_dl,
542 void *sym, char *dlpath, myf MyFlags)
543{
544 DBUG_ENTER("read_maria_plugin_info");
545 /* Determine interface version */
546 if (!sym)
547 {
548 if (!opt_silent_startup)
549 my_error(ER_CANT_FIND_DL_ENTRY, MyFlags, plugin_interface_version_sym,
550 dlpath);
551 DBUG_RETURN(TRUE);
552 }
553 plugin_dl->mariaversion= 0;
554 plugin_dl->mysqlversion= *(int *)sym;
555 /* Versioning */
556 if (plugin_dl->mysqlversion < min_plugin_interface_version ||
557 (plugin_dl->mysqlversion >> 8) > (MYSQL_PLUGIN_INTERFACE_VERSION >> 8))
558 {
559 my_error(ER_CANT_OPEN_LIBRARY, MyFlags, dlpath, ENOEXEC,
560 "plugin interface version mismatch");
561 DBUG_RETURN(TRUE);
562 }
563 /* Find plugin declarations */
564 if (!(sym= dlsym(plugin_dl->handle, plugin_declarations_sym)))
565 {
566 my_error(ER_CANT_FIND_DL_ENTRY, MyFlags, plugin_declarations_sym, dlpath);
567 DBUG_RETURN(TRUE);
568 }
569
570 /* convert mysql declaration to maria one */
571 {
572 int i;
573 uint sizeof_st_plugin;
574 struct st_mysql_plugin *old;
575 struct st_maria_plugin *cur;
576 char *ptr= (char *)sym;
577
578 if ((sym= dlsym(plugin_dl->handle, sizeof_st_plugin_sym)))
579 sizeof_st_plugin= *(int *)sym;
580 else
581 {
582 DBUG_ASSERT(min_plugin_interface_version == 0);
583 sizeof_st_plugin= (int)offsetof(struct st_mysql_plugin, version);
584 }
585
586 for (i= 0;
587 ((struct st_mysql_plugin *)(ptr + i * sizeof_st_plugin))->info;
588 i++)
589 /* no op */;
590
591 cur= (struct st_maria_plugin*)
592 my_malloc(key_memory_mysql_plugin, (i + 1) * sizeof(struct st_maria_plugin),
593 MYF(MY_ZEROFILL|MY_WME));
594 if (!cur)
595 {
596 my_error(ER_OUTOFMEMORY, MyFlags,
597 static_cast<int>(plugin_dl->dl.length));
598 DBUG_RETURN(TRUE);

Callers 1

plugin_dl_addFunction · 0.85

Calls 2

my_errorFunction · 0.85
my_mallocFunction · 0.85

Tested by

no test coverage detected