Commit e231da19 authored by unknown's avatar unknown

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.


include/mysql/plugin.h:
  wl2936
    slip in const modifier for default values,
    this removes compiler warnings when assigning a string const as default value.
sql/derror.cc:
  WL2936
    Allow init_errmessage() to return upon failure.
    Initialize errmesg to an array of empty strings if it failed to load errmsg.sys
sql/mysqld.cc:
  wl2936
    Include Ingo's compiler-warnings fix.
    If init_errmessage() failed to load errmsg.sys, abort.
    Failure to set working directory not fatal when '--help' is specified, as
    server will terminate anyway after displaying help information.
sql/sql_plugin.cc:
  wl2936
    complete change of SET vars from ulong to ulonglong.
parent 4205d01e
......@@ -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)
......
......@@ -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 @@ Check that the above file is the right version for this program!",
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 */
......
......@@ -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
......
......@@ -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'.",
......
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