From ff3da0f963b28d128005da8ca5d0c93a72d34b27 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 28 Feb 2011 12:48:50 +0200 Subject: Change TABLE->alias to String for less memory reallocation Changed some String.ptr() -> String.c_ptr() for String that are not guaranteed to end with \0 Removed some c_ptr() usage from parameters to functions that takes ptr & length Use preallocate buffers to avoid calling malloc() for most operations. sql/event_db_repository.cc: alias is now a String sql/event_scheduler.cc: c_ptr -> c_ptr_safe() to avoid warnings from valgrind. sql/events.cc: c_ptr -> c_ptr_safe() to avoid warnings from valgrind. c_ptr -> ptr() as function takes ptr & length sql/field.cc: alias is now a String sql/field.h: alias is now a String sql/ha_partition.cc: alias is now a String sql/handler.cc: alias is now a String ptr() -> c_ptr() as string is not guaranteed to be \0 terminated sql/item.cc: Store error parameter in separarte buffer to ensure correct error message sql/item_func.cc: ptr() -> c_ptr_safe() as string is not guaranteed to be \0 terminated sql/item_sum.h: Use my_strtod() instead of my_atof() to not have to make string \0 terminated sql/lock.cc: alias is now a String sql/log.cc: c_ptr() -> ptr() as function takes ptr & length sql/log_event.cc: c_ptr_quick() -> ptr() as we only want to get the pointer to String buffer sql/opt_range.cc: ptr() -> c_ptr() as string is not guaranteed to be \0 terminated sql/opt_table_elimination.cc: alias is now a String sql/set_var.cc: ptr() -> c_ptr() as string is not guaranteed to be \0 terminated c_ptr() -> c_ptr_safe() to avoid warnings from valgrind. c_ptr() -> ptr() as function takes ptr & length Simplify some code. sql/sp.cc: c_ptr() -> ptr() as function takes ptr & length sql/sp_rcontext.cc: alias is now a String sql/sql_base.cc: alias is now a String. Here we win a realloc() for most alias usage. sql/sql_class.cc: Use size descriptor for printf() to avoid accessing bytes outside of buffer sql/sql_insert.cc: Change allocation of TABLE as it's now contains a String _ptr() -> ptr() as function takes ptr & length sql/sql_load.cc: Use preallocate buffers to avoid calling malloc() for most operations. sql/sql_parse.cc: Use c_ptr_safe() to ensure string is \0 terminated. sql/sql_plugin.cc: c_ptr_quick() -> ptr() as function takes ptr & length sql/sql_select.cc: alias is now a String sql/sql_show.cc: alias is now a String sql/sql_string.h: Added move() function to change who owns the string (owner does the free) sql/sql_table.cc: alias is now a String c_ptr() -> c_ptr_safe() to avoid warnings from valgrind. sql/sql_test.cc: c_ptr() -> c_ptr_safe() to avoid warnings from valgrind. alias is now a String sql/sql_trigger.cc: c_ptr() -> c_ptr_safe() to avoid warnings from valgrind. Use field->init() to setup pointers to alias. sql/sql_update.cc: alias is now a String sql/sql_view.cc: ptr() -> c_ptr_safe() as string is not guaranteed to be \0 terminated sql/sql_yacc.yy: r() -> c_ptr() as string is not guaranteed to be \0 terminated sql/table.cc: alias is now a String sql/table.h: alias is now a String storage/federatedx/ha_federatedx.cc: Remove extra 1 byte alloc that is automaticly done by strmake() Ensure that error message ends with \0 storage/maria/ha_maria.cc: alias is now a String storage/myisam/ha_myisam.cc: alias is now a String --- sql/sql_plugin.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_plugin.cc') diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index dd908e1b60e..58cc7dc93a9 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -303,7 +303,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()); } -- cgit v1.2.1 From 2740edcf5680bc03a318378514f88fefa67d5923 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Tue, 7 Jun 2011 10:54:37 +0300 Subject: Fixed that mysqld --no-defaults --help --verbose doesn't give a lot of irrelevant error messages. sql/mysql_priv.h: Make opt_help global sql/mysqld.cc: Don't give (double) warnings about lower case file systems if --help is given. Don't give warning about non existing data directory if --help is given. sql/sql_plugin.cc: Give a better warning if --help is used and plugin table doesn't exists --- sql/sql_plugin.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'sql/sql_plugin.cc') diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 391a574b35d..a83990d25f4 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1638,8 +1638,11 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv) if (simple_open_n_lock_tables(new_thd, &tables)) { 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; -- cgit v1.2.1 From 135ce0ba6c9457c4c968b420a16e5bda69f222e0 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 21 Jun 2011 17:40:51 +0200 Subject: lp:790513 MariaDB crashes on startup initialize plugins earlier, to support, for example, non-MyISAM mysql.plugin table. --- sql/sql_plugin.cc | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'sql/sql_plugin.cc') 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); -- cgit v1.2.1