diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index fd43e9688d0..7b224695324 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -193,7 +193,8 @@ typedef void (*mysql_var_update_func)(MYSQL_THD thd, #define DECLARE_MYSQL_SYSVAR_BASIC(name, type) struct { \ MYSQL_PLUGIN_VAR_HEADER; \ - type *value; type def_val; \ + type *value; \ + const type def_val; \ } MYSQL_SYSVAR_NAME(name) #define DECLARE_MYSQL_SYSVAR_SIMPLE(name, type) struct { \ @@ -215,7 +216,7 @@ typedef void (*mysql_var_update_func)(MYSQL_THD thd, #define DECLARE_MYSQL_THDVAR_BASIC(name, type) struct { \ MYSQL_PLUGIN_VAR_HEADER; \ int offset; \ - type def_val; \ + const type def_val; \ DECLARE_THDVAR_FUNC(type); \ } MYSQL_SYSVAR_NAME(name) diff --git a/sql/derror.cc b/sql/derror.cc index 0e74d411b1f..eca553d1bf8 100644 --- a/sql/derror.cc +++ b/sql/derror.cc @@ -31,6 +31,9 @@ static void init_myfunc_errs(void); DESCRIPTION This function can be called multiple times to reload the messages. + If it fails to load the messages, it will fail softly by initializing + the errmesg pointer to an array of empty strings or by keeping the + old array if it exists. RETURN FALSE OK @@ -39,7 +42,7 @@ static void init_myfunc_errs(void); bool init_errmessage(void) { - const char **errmsgs; + const char **errmsgs, **ptr; DBUG_ENTER("init_errmessage"); /* @@ -49,8 +52,15 @@ bool init_errmessage(void) errmsgs= my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST); /* Read messages from file. */ - if (read_texts(ERRMSG_FILE, &errmsgs, ER_ERROR_LAST - ER_ERROR_FIRST + 1)) - DBUG_RETURN(TRUE); + if (read_texts(ERRMSG_FILE, &errmsgs, ER_ERROR_LAST - ER_ERROR_FIRST + 1) && + !errmsgs) + { + if (!(errmsgs= (const char**) my_malloc((ER_ERROR_LAST-ER_ERROR_FIRST+1)* + sizeof(char*), MYF(0)))) + DBUG_RETURN(TRUE); + for (ptr= errmsgs; ptr < errmsgs + ER_ERROR_LAST - ER_ERROR_FIRST; ptr++) + *ptr= ""; + } /* Register messages for use with my_error(). */ if (my_error_register(errmsgs, ER_ERROR_FIRST, ER_ERROR_LAST)) @@ -66,7 +76,6 @@ bool init_errmessage(void) /* Read text from packed textfile in language-directory */ - /* If we can't read messagefile then it's panic- we can't continue */ static bool read_texts(const char *file_name,const char ***point, uint error_messages) @@ -79,7 +88,6 @@ static bool read_texts(const char *file_name,const char ***point, uchar head[32],*pos; DBUG_ENTER("read_texts"); - *point=0; // If something goes wrong LINT_INIT(buff); funktpos=0; if ((file=my_open(fn_format(name,file_name,language,"",4), @@ -119,7 +127,7 @@ but it should contain at least %d error messages.\n\ Check that the above file is the right version for this program!", name,count,error_messages); VOID(my_close(file,MYF(MY_WME))); - unireg_abort(1); + DBUG_RETURN(1); } x_free((gptr) *point); /* Free old language */ @@ -162,8 +170,7 @@ err: err1: if (file != FERR) VOID(my_close(file,MYF(MY_WME))); - unireg_abort(1); - DBUG_RETURN(1); // keep compiler happy + DBUG_RETURN(1); } /* read_texts */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index a2956b7e53a..fcb372e1c92 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1331,6 +1331,7 @@ static void clean_up_mutexes() ** Init IP and UNIX socket ****************************************************************************/ +#ifndef EMBEDDED_LIBRARY static void set_ports() { char *env; @@ -1355,7 +1356,6 @@ static void set_ports() } } -#ifndef EMBEDDED_LIBRARY /* Change to run as another user if started with --user */ static struct passwd *check_user(const char *user) @@ -2614,16 +2614,18 @@ int STDCALL handle_kill(ulong ctrl_type) } #endif +#if !defined(EMBEDDED_LIBRARY) static const char *load_default_groups[]= { #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE "mysql_cluster", #endif "mysqld","server", MYSQL_BASE_VERSION, 0, 0}; -#if defined(__WIN__) && !defined(EMBEDDED_LIBRARY) +#if defined(__WIN__) static const int load_default_groups_sz= sizeof(load_default_groups)/sizeof(load_default_groups[0]); #endif +#endif /*!EMBEDDED_LIBRARY*/ /* @@ -3384,6 +3386,10 @@ server."); } } + /* if the errmsg.sys is not loaded, terminate to maintain behaviour */ + if (!errmesg[0][0]) + unireg_abort(1); + /* We have to initialize the storage engines before CSV logging */ if (ha_init()) { @@ -3743,7 +3749,7 @@ int main(int argc, char **argv) We have enough space for fiddling with the argv, continue */ check_data_home(mysql_real_data_home); - if (my_setwd(mysql_real_data_home,MYF(MY_WME))) + if (my_setwd(mysql_real_data_home,MYF(MY_WME)) && !opt_help) unireg_abort(1); /* purecov: inspected */ mysql_data_home= mysql_data_home_buff; mysql_data_home[0]=FN_CURLIB; // all paths are relative from here diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index a9816eb4f98..590fee82027 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1939,8 +1939,7 @@ static int check_func_set(THD *thd, struct st_mysql_sys_var *var, char buff[STRING_BUFFER_USUAL_SIZE], *error= 0; const char *strvalue= "NULL", *str; TYPELIB *typelib; - long result; - ulonglong tmp; + ulonglong result; uint error_len; bool not_used; int length; @@ -1966,18 +1965,17 @@ static int check_func_set(THD *thd, struct st_mysql_sys_var *var, } else { - if (value->val_int(value, (long long *)&tmp)) + if (value->val_int(value, (long long *)&result)) goto err; - if (unlikely((tmp >= (ULL(1) << typelib->count)) && + if (unlikely((result >= (ULL(1) << typelib->count)) && (typelib->count < sizeof(long)*8))) { - llstr(tmp, buff); + llstr(result, buff); strvalue= buff; goto err; } - result= (long) tmp; } - *(long*)save= result; + *(ulonglong*)save= result; return 0; err: my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->name, strvalue); @@ -2887,7 +2885,7 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, if (!opt->check) opt->check= check_func_set; if (!opt->update) - opt->update= update_func_long; + opt->update= update_func_longlong; break; default: sql_print_error("Unknown variable type code 0x%x in plugin '%s'.",