diff options
Diffstat (limited to 'sql/sql_plugin.cc')
-rw-r--r-- | sql/sql_plugin.cc | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 5e46a5ebf82..b725f1c35fc 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -351,7 +351,7 @@ static const char *item_val_str(struct st_mysql_value *value, Lets be nice and create a temporary string since the buffer was too small */ - return current_thd->strmake(res->c_ptr_quick(), res->length()); + return current_thd->strmake(res->ptr(), res->length()); } @@ -1512,15 +1512,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 @@ -1672,8 +1680,11 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv) if (result) { DBUG_PRINT("error",("Can't open plugin table")); - sql_print_error("Can't open the mysql.plugin table. Please " - "run mysql_upgrade to create it."); + if (!opt_help) + sql_print_error("Can't open the mysql.plugin table. Please " + "run mysql_upgrade to create it."); + else + sql_print_warning("Could not open mysql.plugin table. Some options may be missing from the help text"); goto end; } table= tables.table; @@ -1684,13 +1695,6 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv) goto end; } 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 mysql_mutex_assert_owner(), so we lock - the mutex here to satisfy the assert - */ - mysql_mutex_lock(&LOCK_plugin); while (!(error= read_record_info.read_record(&read_record_info))) { DBUG_PRINT("info", ("init plugin record")); @@ -1701,12 +1705,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 mysql_mutex_assert_owner(), so we lock + the mutex here to satisfy the assert + */ + mysql_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)); + mysql_mutex_unlock(&LOCK_plugin); } - mysql_mutex_unlock(&LOCK_plugin); if (error > 0) sql_print_error(ER(ER_GET_ERRNO), my_errno); end_read_record(&read_record_info); |