summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2011-06-21 17:40:51 +0200
committerSergei Golubchik <sergii@pisem.net>2011-06-21 17:40:51 +0200
commit135ce0ba6c9457c4c968b420a16e5bda69f222e0 (patch)
tree837654847eb87ba88b3d2e87cf174e3b661fd475 /sql
parent018614e2b348598f4518e11156fb44c388d2bf32 (diff)
downloadmariadb-git-135ce0ba6c9457c4c968b420a16e5bda69f222e0.tar.gz
lp:790513 MariaDB crashes on startup
initialize plugins earlier, to support, for example, non-MyISAM mysql.plugin table.
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_plugin.cc40
1 files changed, 24 insertions, 16 deletions
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 3f5d143ecf1..dbbcd7e8c86 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -1232,15 +1232,23 @@ int plugin_init(int *argc, char **argv, int flags)
if (register_builtin(plugin, &tmp, &plugin_ptr))
goto err_unlock;
- /* only initialize MyISAM and CSV at this stage */
- if (!(is_myisam=
- !my_strcasecmp(&my_charset_latin1, plugin->name, "MyISAM")) &&
- my_strcasecmp(&my_charset_latin1, plugin->name, "CSV"))
- continue;
+ is_myisam= !my_strcasecmp(&my_charset_latin1, plugin->name, "MyISAM");
- if (plugin_ptr->state == PLUGIN_IS_UNINITIALIZED &&
- plugin_initialize(plugin_ptr))
- goto err_unlock;
+ /*
+ strictly speaking, we should to initialize all plugins,
+ even for mysqld --help, because important subsystems
+ may be disabled otherwise, and the help will be incomplete.
+ For example, if the mysql.plugin table is not MyISAM.
+ But for now it's an unlikely corner case, and to optimize
+ mysqld --help for all other users, we will only initialize
+ MyISAM here.
+ */
+ if (!(flags & PLUGIN_INIT_SKIP_INITIALIZATION) || is_myisam)
+ {
+ if (plugin_ptr->state == PLUGIN_IS_UNINITIALIZED &&
+ plugin_initialize(plugin_ptr))
+ goto err_unlock;
+ }
/*
initialize the global default storage engine so that it may
@@ -1445,13 +1453,6 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv)
table= tables.table;
init_read_record(&read_record_info, new_thd, table, NULL, 1, 0, FALSE);
table->use_all_columns();
- /*
- there're no other threads running yet, so we don't need a mutex.
- but plugin_add() before is designed to work in multi-threaded
- environment, and it uses safe_mutex_assert_owner(), so we lock
- the mutex here to satisfy the assert
- */
- pthread_mutex_lock(&LOCK_plugin);
while (!(error= read_record_info.read_record(&read_record_info)))
{
DBUG_PRINT("info", ("init plugin record"));
@@ -1462,12 +1463,19 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv)
LEX_STRING name= {(char *)str_name.ptr(), str_name.length()};
LEX_STRING dl= {(char *)str_dl.ptr(), str_dl.length()};
+ /*
+ there're no other threads running yet, so we don't need a mutex.
+ but plugin_add() before is designed to work in multi-threaded
+ environment, and it uses safe_mutex_assert_owner(), so we lock
+ the mutex here to satisfy the assert
+ */
+ pthread_mutex_lock(&LOCK_plugin);
if (plugin_add(tmp_root, &name, &dl, argc, argv, REPORT_TO_LOG))
sql_print_warning("Couldn't load plugin named '%s' with soname '%s'.",
str_name.c_ptr(), str_dl.c_ptr());
free_root(tmp_root, MYF(MY_MARK_BLOCKS_FREE));
+ pthread_mutex_unlock(&LOCK_plugin);
}
- pthread_mutex_unlock(&LOCK_plugin);
if (error > 0)
sql_print_error(ER(ER_GET_ERRNO), my_errno);
end_read_record(&read_record_info);