Commit 390afdd1 authored by Sergey Glukhov's avatar Sergey Glukhov

Bug#42610 Dynamic plugin broken in 5.1.31

--added ability to obtain plugin variables from my.cnf on INSTALL PLUGIN stage
--option 'ignore-builtin-innodb' disables all InnoDB builtin plugins
  (including I_S plugins)
parent ec39e58d
...@@ -2047,6 +2047,9 @@ extern SHOW_COMP_OPTION have_geometry, have_rtree_keys; ...@@ -2047,6 +2047,9 @@ extern SHOW_COMP_OPTION have_geometry, have_rtree_keys;
extern SHOW_COMP_OPTION have_crypt; extern SHOW_COMP_OPTION have_crypt;
extern SHOW_COMP_OPTION have_compress; extern SHOW_COMP_OPTION have_compress;
extern int orig_argc;
extern char **orig_argv;
extern const char *load_default_groups[];
#ifndef __WIN__ #ifndef __WIN__
extern pthread_t signal_thread; extern pthread_t signal_thread;
......
...@@ -648,6 +648,9 @@ static int defaults_argc; ...@@ -648,6 +648,9 @@ static int defaults_argc;
static char **defaults_argv; static char **defaults_argv;
static char *opt_bin_logname; static char *opt_bin_logname;
int orig_argc;
char **orig_argv;
static my_socket unix_sock,ip_sock; static my_socket unix_sock,ip_sock;
struct rand_struct sql_rand; ///< used by sql_class.cc:THD::THD() struct rand_struct sql_rand; ///< used by sql_class.cc:THD::THD()
...@@ -2923,7 +2926,7 @@ pthread_handler_t handle_shutdown(void *arg) ...@@ -2923,7 +2926,7 @@ pthread_handler_t handle_shutdown(void *arg)
#endif #endif
#if !defined(EMBEDDED_LIBRARY) #if !defined(EMBEDDED_LIBRARY)
static const char *load_default_groups[]= { const char *load_default_groups[]= {
#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
"mysql_cluster", "mysql_cluster",
#endif #endif
...@@ -3221,6 +3224,8 @@ static int init_common_variables(const char *conf_file_name, int argc, ...@@ -3221,6 +3224,8 @@ static int init_common_variables(const char *conf_file_name, int argc,
SQLCOM_END + 8); SQLCOM_END + 8);
#endif #endif
orig_argc=argc;
orig_argv=argv;
load_defaults(conf_file_name, groups, &argc, &argv); load_defaults(conf_file_name, groups, &argc, &argv);
defaults_argv=argv; defaults_argv=argv;
defaults_argc=argc; defaults_argc=argc;
...@@ -3886,6 +3891,7 @@ server."); ...@@ -3886,6 +3891,7 @@ server.");
if ((ho_error= handle_options(&defaults_argc, &tmp_argv, no_opts, if ((ho_error= handle_options(&defaults_argc, &tmp_argv, no_opts,
mysqld_get_one_option))) mysqld_get_one_option)))
unireg_abort(ho_error); unireg_abort(ho_error);
my_getopt_skip_unknown= TRUE;
if (defaults_argc) if (defaults_argc)
{ {
......
...@@ -1139,7 +1139,8 @@ int plugin_init(int *argc, char **argv, int flags) ...@@ -1139,7 +1139,8 @@ int plugin_init(int *argc, char **argv, int flags)
for (plugin= *builtins; plugin->info; plugin++) for (plugin= *builtins; plugin->info; plugin++)
{ {
if (opt_ignore_builtin_innodb && if (opt_ignore_builtin_innodb &&
!my_strcasecmp(&my_charset_latin1, plugin->name, "InnoDB")) !my_strnncoll(&my_charset_latin1, (const uchar*) plugin->name,
6, (const uchar*) "InnoDB", 6))
continue; continue;
/* by default, ndbcluster and federated are disabled */ /* by default, ndbcluster and federated are disabled */
def_enabled= def_enabled=
...@@ -1633,8 +1634,8 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING *dl ...@@ -1633,8 +1634,8 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING *dl
{ {
TABLE_LIST tables; TABLE_LIST tables;
TABLE *table; TABLE *table;
int error, argc; int error, argc=orig_argc;
char *argv[2]; char **argv=orig_argv;
struct st_plugin_int *tmp; struct st_plugin_int *tmp;
DBUG_ENTER("mysql_install_plugin"); DBUG_ENTER("mysql_install_plugin");
...@@ -1650,22 +1651,32 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING *dl ...@@ -1650,22 +1651,32 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING *dl
pthread_mutex_lock(&LOCK_plugin); pthread_mutex_lock(&LOCK_plugin);
rw_wrlock(&LOCK_system_variables_hash); rw_wrlock(&LOCK_system_variables_hash);
/* handle_options() assumes arg0 (program name) always exists */
argv[0]= const_cast<char*>(""); // without a cast gcc emits a warning load_defaults(MYSQL_CONFIG_NAME, load_default_groups, &argc, &argv);
argv[1]= 0;
argc= 1;
error= plugin_add(thd->mem_root, name, dl, &argc, argv, REPORT_TO_USER); error= plugin_add(thd->mem_root, name, dl, &argc, argv, REPORT_TO_USER);
if (argv)
free_defaults(argv);
rw_unlock(&LOCK_system_variables_hash); rw_unlock(&LOCK_system_variables_hash);
if (error || !(tmp= plugin_find_internal(name, MYSQL_ANY_PLUGIN))) if (error || !(tmp= plugin_find_internal(name, MYSQL_ANY_PLUGIN)))
goto err; goto err;
if (tmp->state == PLUGIN_IS_DISABLED)
{
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_CANT_INITIALIZE_UDF, ER(ER_CANT_INITIALIZE_UDF),
name->str, "Plugin is disabled");
}
else
{
DBUG_ASSERT(tmp->state == PLUGIN_IS_UNINITIALIZED);
if (plugin_initialize(tmp)) if (plugin_initialize(tmp))
{ {
my_error(ER_CANT_INITIALIZE_UDF, MYF(0), name->str, my_error(ER_CANT_INITIALIZE_UDF, MYF(0), name->str,
"Plugin initialization function failed."); "Plugin initialization function failed.");
goto deinit; goto deinit;
} }
}
/* /*
We do not replicate the INSTALL PLUGIN statement. Disable binlogging We do not replicate the INSTALL PLUGIN statement. Disable binlogging
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment