WL#2936

  Fix compiler warnings,
  Fix help output - this fixes im test failures.
  Fix incomplete change of SET plugin vars to ulonglong.
  Allow ER() to work without crashing when errmsg.sys has not been loaded.
parent a2e63487
...@@ -193,7 +193,8 @@ typedef void (*mysql_var_update_func)(MYSQL_THD thd, ...@@ -193,7 +193,8 @@ typedef void (*mysql_var_update_func)(MYSQL_THD thd,
#define DECLARE_MYSQL_SYSVAR_BASIC(name, type) struct { \ #define DECLARE_MYSQL_SYSVAR_BASIC(name, type) struct { \
MYSQL_PLUGIN_VAR_HEADER; \ MYSQL_PLUGIN_VAR_HEADER; \
type *value; type def_val; \ type *value; \
const type def_val; \
} MYSQL_SYSVAR_NAME(name) } MYSQL_SYSVAR_NAME(name)
#define DECLARE_MYSQL_SYSVAR_SIMPLE(name, type) struct { \ #define DECLARE_MYSQL_SYSVAR_SIMPLE(name, type) struct { \
...@@ -215,7 +216,7 @@ typedef void (*mysql_var_update_func)(MYSQL_THD thd, ...@@ -215,7 +216,7 @@ typedef void (*mysql_var_update_func)(MYSQL_THD thd,
#define DECLARE_MYSQL_THDVAR_BASIC(name, type) struct { \ #define DECLARE_MYSQL_THDVAR_BASIC(name, type) struct { \
MYSQL_PLUGIN_VAR_HEADER; \ MYSQL_PLUGIN_VAR_HEADER; \
int offset; \ int offset; \
type def_val; \ const type def_val; \
DECLARE_THDVAR_FUNC(type); \ DECLARE_THDVAR_FUNC(type); \
} MYSQL_SYSVAR_NAME(name) } MYSQL_SYSVAR_NAME(name)
......
...@@ -31,6 +31,9 @@ static void init_myfunc_errs(void); ...@@ -31,6 +31,9 @@ static void init_myfunc_errs(void);
DESCRIPTION DESCRIPTION
This function can be called multiple times to reload the messages. 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 RETURN
FALSE OK FALSE OK
...@@ -39,7 +42,7 @@ static void init_myfunc_errs(void); ...@@ -39,7 +42,7 @@ static void init_myfunc_errs(void);
bool init_errmessage(void) bool init_errmessage(void)
{ {
const char **errmsgs; const char **errmsgs, **ptr;
DBUG_ENTER("init_errmessage"); DBUG_ENTER("init_errmessage");
/* /*
...@@ -49,8 +52,15 @@ bool init_errmessage(void) ...@@ -49,8 +52,15 @@ bool init_errmessage(void)
errmsgs= my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST); errmsgs= my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST);
/* Read messages from file. */ /* Read messages from file. */
if (read_texts(ERRMSG_FILE, &errmsgs, ER_ERROR_LAST - ER_ERROR_FIRST + 1)) if (read_texts(ERRMSG_FILE, &errmsgs, ER_ERROR_LAST - ER_ERROR_FIRST + 1) &&
DBUG_RETURN(TRUE); !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(). */ /* Register messages for use with my_error(). */
if (my_error_register(errmsgs, ER_ERROR_FIRST, ER_ERROR_LAST)) if (my_error_register(errmsgs, ER_ERROR_FIRST, ER_ERROR_LAST))
...@@ -66,7 +76,6 @@ bool init_errmessage(void) ...@@ -66,7 +76,6 @@ bool init_errmessage(void)
/* Read text from packed textfile in language-directory */ /* 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, static bool read_texts(const char *file_name,const char ***point,
uint error_messages) uint error_messages)
...@@ -79,7 +88,6 @@ static bool read_texts(const char *file_name,const char ***point, ...@@ -79,7 +88,6 @@ static bool read_texts(const char *file_name,const char ***point,
uchar head[32],*pos; uchar head[32],*pos;
DBUG_ENTER("read_texts"); DBUG_ENTER("read_texts");
*point=0; // If something goes wrong
LINT_INIT(buff); LINT_INIT(buff);
funktpos=0; funktpos=0;
if ((file=my_open(fn_format(name,file_name,language,"",4), 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\ ...@@ -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!", Check that the above file is the right version for this program!",
name,count,error_messages); name,count,error_messages);
VOID(my_close(file,MYF(MY_WME))); VOID(my_close(file,MYF(MY_WME)));
unireg_abort(1); DBUG_RETURN(1);
} }
x_free((gptr) *point); /* Free old language */ x_free((gptr) *point); /* Free old language */
...@@ -162,8 +170,7 @@ err: ...@@ -162,8 +170,7 @@ err:
err1: err1:
if (file != FERR) if (file != FERR)
VOID(my_close(file,MYF(MY_WME))); VOID(my_close(file,MYF(MY_WME)));
unireg_abort(1); DBUG_RETURN(1);
DBUG_RETURN(1); // keep compiler happy
} /* read_texts */ } /* read_texts */
......
...@@ -1331,6 +1331,7 @@ static void clean_up_mutexes() ...@@ -1331,6 +1331,7 @@ static void clean_up_mutexes()
** Init IP and UNIX socket ** Init IP and UNIX socket
****************************************************************************/ ****************************************************************************/
#ifndef EMBEDDED_LIBRARY
static void set_ports() static void set_ports()
{ {
char *env; char *env;
...@@ -1355,7 +1356,6 @@ static void set_ports() ...@@ -1355,7 +1356,6 @@ static void set_ports()
} }
} }
#ifndef EMBEDDED_LIBRARY
/* Change to run as another user if started with --user */ /* Change to run as another user if started with --user */
static struct passwd *check_user(const char *user) static struct passwd *check_user(const char *user)
...@@ -2614,16 +2614,18 @@ int STDCALL handle_kill(ulong ctrl_type) ...@@ -2614,16 +2614,18 @@ int STDCALL handle_kill(ulong ctrl_type)
} }
#endif #endif
#if !defined(EMBEDDED_LIBRARY)
static const char *load_default_groups[]= { static const char *load_default_groups[]= {
#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
"mysql_cluster", "mysql_cluster",
#endif #endif
"mysqld","server", MYSQL_BASE_VERSION, 0, 0}; "mysqld","server", MYSQL_BASE_VERSION, 0, 0};
#if defined(__WIN__) && !defined(EMBEDDED_LIBRARY) #if defined(__WIN__)
static const int load_default_groups_sz= static const int load_default_groups_sz=
sizeof(load_default_groups)/sizeof(load_default_groups[0]); sizeof(load_default_groups)/sizeof(load_default_groups[0]);
#endif #endif
#endif /*!EMBEDDED_LIBRARY*/
/* /*
...@@ -3384,6 +3386,10 @@ server."); ...@@ -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 */ /* We have to initialize the storage engines before CSV logging */
if (ha_init()) if (ha_init())
{ {
...@@ -3743,7 +3749,7 @@ int main(int argc, char **argv) ...@@ -3743,7 +3749,7 @@ int main(int argc, char **argv)
We have enough space for fiddling with the argv, continue We have enough space for fiddling with the argv, continue
*/ */
check_data_home(mysql_real_data_home); 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 */ unireg_abort(1); /* purecov: inspected */
mysql_data_home= mysql_data_home_buff; mysql_data_home= mysql_data_home_buff;
mysql_data_home[0]=FN_CURLIB; // all paths are relative from here mysql_data_home[0]=FN_CURLIB; // all paths are relative from here
......
...@@ -1939,8 +1939,7 @@ static int check_func_set(THD *thd, struct st_mysql_sys_var *var, ...@@ -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; char buff[STRING_BUFFER_USUAL_SIZE], *error= 0;
const char *strvalue= "NULL", *str; const char *strvalue= "NULL", *str;
TYPELIB *typelib; TYPELIB *typelib;
long result; ulonglong result;
ulonglong tmp;
uint error_len; uint error_len;
bool not_used; bool not_used;
int length; int length;
...@@ -1966,18 +1965,17 @@ static int check_func_set(THD *thd, struct st_mysql_sys_var *var, ...@@ -1966,18 +1965,17 @@ static int check_func_set(THD *thd, struct st_mysql_sys_var *var,
} }
else else
{ {
if (value->val_int(value, (long long *)&tmp)) if (value->val_int(value, (long long *)&result))
goto err; goto err;
if (unlikely((tmp >= (ULL(1) << typelib->count)) && if (unlikely((result >= (ULL(1) << typelib->count)) &&
(typelib->count < sizeof(long)*8))) (typelib->count < sizeof(long)*8)))
{ {
llstr(tmp, buff); llstr(result, buff);
strvalue= buff; strvalue= buff;
goto err; goto err;
} }
result= (long) tmp;
} }
*(long*)save= result; *(ulonglong*)save= result;
return 0; return 0;
err: err:
my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), var->name, strvalue); 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, ...@@ -2887,7 +2885,7 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp,
if (!opt->check) if (!opt->check)
opt->check= check_func_set; opt->check= check_func_set;
if (!opt->update) if (!opt->update)
opt->update= update_func_long; opt->update= update_func_longlong;
break; break;
default: default:
sql_print_error("Unknown variable type code 0x%x in plugin '%s'.", sql_print_error("Unknown variable type code 0x%x in plugin '%s'.",
......
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