mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 11:27:39 +02:00
BUG# 4466 - Nothing in .err when mysql service ends because of malformed my.ini options
mysqld.cc: Changed option_error_reporter to match new function header that includes LOGLEVEL enum mysql_priv.h: Removed the MY_ERROR style bitmask. Changed function headers to use new LOGLEVEL enum log.cc: Changed print_buffer_to_log to print_buffer_to_file. Remove the timestamp bool and now all log entries written to stderr are timestamped. Removed some unused commented code. changed to use the new LOGLEVEL enum. my_getopt.c: Changed functions to use the new LOGLEVEL enum and changed the included error reporter to be default_reporter. This reporter is used in handle_options if a reporter is not given my_getopt.h: changed typedefs to use better naming convention. Moved error bitmask into the LOGLEVEL enum and included it here.
This commit is contained in:
parent
67003d1c98
commit
a22cdab9e9
5 changed files with 127 additions and 120 deletions
|
|
@ -56,17 +56,11 @@ char *disabled_my_option= (char*) "0";
|
|||
|
||||
my_bool my_getopt_print_errors= 1;
|
||||
|
||||
void report_option_error( hoErrorReporter reporter, const char *format, ... )
|
||||
void default_reporter( enum LOGLEVEL level, const char *format, ... )
|
||||
{
|
||||
va_list args;
|
||||
va_start( args, format );
|
||||
|
||||
|
||||
if (reporter != NULL)
|
||||
reporter( format, args );
|
||||
else
|
||||
vfprintf( stderr, format, args );
|
||||
|
||||
vfprintf( stderr, format, args );
|
||||
va_end( args );
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +75,8 @@ void report_option_error( hoErrorReporter reporter, const char *format, ... )
|
|||
*/
|
||||
|
||||
int handle_options(int *argc, char ***argv,
|
||||
const struct my_option *longopts, hoGetOneOption get_one_option, hoErrorReporter reporter )
|
||||
const struct my_option *longopts, my_get_one_option get_one_option,
|
||||
my_error_reporter reporter )
|
||||
{
|
||||
uint opt_found, argvpos= 0, length, i;
|
||||
my_bool end_of_options= 0, must_be_var, set_maximum_value, special_used,
|
||||
|
|
@ -95,6 +90,8 @@ int handle_options(int *argc, char ***argv,
|
|||
(*argv)++; /* --- || ---- */
|
||||
init_variables(longopts);
|
||||
|
||||
if (! reporter) reporter = &default_reporter;
|
||||
|
||||
for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++)
|
||||
{
|
||||
char *cur_arg= *pos;
|
||||
|
|
@ -119,8 +116,7 @@ int handle_options(int *argc, char ***argv,
|
|||
if (!*++pos)
|
||||
{
|
||||
if (my_getopt_print_errors)
|
||||
report_option_error(reporter, "%s: Option '-O' requires an argument\n",
|
||||
progname);
|
||||
reporter( ERROR_LEVEL, "%s: Option '-O' requires an argument\n", progname );
|
||||
return EXIT_ARGUMENT_REQUIRED;
|
||||
}
|
||||
cur_arg= *pos;
|
||||
|
|
@ -136,9 +132,7 @@ int handle_options(int *argc, char ***argv,
|
|||
if (!*cur_arg)
|
||||
{
|
||||
if (my_getopt_print_errors)
|
||||
report_option_error(reporter,
|
||||
"%s: Option '--set-variable' requires an argument\n",
|
||||
progname);
|
||||
reporter( ERROR_LEVEL, "%s: Option '--set-variable' requires an argument\n", progname );
|
||||
return EXIT_ARGUMENT_REQUIRED;
|
||||
}
|
||||
}
|
||||
|
|
@ -150,9 +144,7 @@ int handle_options(int *argc, char ***argv,
|
|||
if (!*++pos)
|
||||
{
|
||||
if (my_getopt_print_errors)
|
||||
report_option_error( reporter,
|
||||
"%s: Option '--set-variable' requires an argument\n",
|
||||
progname);
|
||||
reporter( ERROR_LEVEL, "%s: Option '--set-variable' requires an argument\n", progname );
|
||||
return EXIT_ARGUMENT_REQUIRED;
|
||||
}
|
||||
cur_arg= *pos;
|
||||
|
|
@ -211,7 +203,7 @@ int handle_options(int *argc, char ***argv,
|
|||
if (opt_found > 1)
|
||||
{
|
||||
if (my_getopt_print_errors)
|
||||
report_option_error( reporter,
|
||||
reporter( ERROR_LEVEL,
|
||||
"%s: ambiguous option '--%s-%s' (--%s-%s)\n",
|
||||
progname, special_opt_prefix[i], cur_arg,
|
||||
special_opt_prefix[i], prev_found);
|
||||
|
|
@ -246,18 +238,16 @@ int handle_options(int *argc, char ***argv,
|
|||
if (must_be_var)
|
||||
{
|
||||
if (my_getopt_print_errors)
|
||||
report_option_error( reporter,
|
||||
"%s: %s: unknown variable '%s'\n", progname,
|
||||
option_is_loose ? "WARNING" : "ERROR", cur_arg);
|
||||
reporter( option_is_loose ? WARNING_LEVEL : ERROR_LEVEL,
|
||||
"%s: unknown variable '%s'\n", progname, cur_arg );
|
||||
if (!option_is_loose)
|
||||
return EXIT_UNKNOWN_VARIABLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (my_getopt_print_errors)
|
||||
report_option_error( reporter,
|
||||
"%s: %s: unknown option '--%s'\n", progname,
|
||||
option_is_loose ? "WARNING" : "ERROR", cur_arg);
|
||||
reporter( option_is_loose ? WARNING_LEVEL : ERROR_LEVEL,
|
||||
"%s: unknown option '--%s'\n", progname, cur_arg );
|
||||
if (!option_is_loose)
|
||||
return EXIT_UNKNOWN_OPTION;
|
||||
}
|
||||
|
|
@ -273,14 +263,14 @@ int handle_options(int *argc, char ***argv,
|
|||
if (must_be_var)
|
||||
{
|
||||
if (my_getopt_print_errors)
|
||||
report_option_error( reporter, "%s: variable prefix '%s' is not unique\n",
|
||||
reporter( ERROR_LEVEL, "%s: variable prefix '%s' is not unique\n",
|
||||
progname, cur_arg);
|
||||
return EXIT_VAR_PREFIX_NOT_UNIQUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (my_getopt_print_errors)
|
||||
report_option_error( reporter, "%s: ambiguous option '--%s' (%s, %s)\n",
|
||||
reporter( ERROR_LEVEL, "%s: ambiguous option '--%s' (%s, %s)\n",
|
||||
progname, cur_arg, prev_found, optp->name);
|
||||
return EXIT_AMBIGUOUS_OPTION;
|
||||
}
|
||||
|
|
@ -288,7 +278,7 @@ int handle_options(int *argc, char ***argv,
|
|||
if (must_be_var && optp->var_type == GET_NO_ARG)
|
||||
{
|
||||
if (my_getopt_print_errors)
|
||||
report_option_error( reporter, "%s: option '%s' cannot take an argument\n",
|
||||
reporter( ERROR_LEVEL, "%s: option '%s' cannot take an argument\n",
|
||||
progname, optp->name);
|
||||
return EXIT_NO_ARGUMENT_ALLOWED;
|
||||
}
|
||||
|
|
@ -297,7 +287,7 @@ int handle_options(int *argc, char ***argv,
|
|||
if (optend && optp->var_type != GET_BOOL)
|
||||
{
|
||||
if (my_getopt_print_errors)
|
||||
report_option_error( reporter, "%s: option '--%s' cannot take an argument\n",
|
||||
reporter( ERROR_LEVEL, "%s: option '--%s' cannot take an argument\n",
|
||||
progname, optp->name);
|
||||
return EXIT_NO_ARGUMENT_ALLOWED;
|
||||
}
|
||||
|
|
@ -335,7 +325,7 @@ int handle_options(int *argc, char ***argv,
|
|||
if (!*++pos)
|
||||
{
|
||||
if (my_getopt_print_errors)
|
||||
report_option_error( reporter, "%s: option '--%s' requires an argument\n",
|
||||
reporter( ERROR_LEVEL, "%s: option '--%s' requires an argument\n",
|
||||
progname, optp->name);
|
||||
return EXIT_ARGUMENT_REQUIRED;
|
||||
}
|
||||
|
|
@ -385,7 +375,7 @@ int handle_options(int *argc, char ***argv,
|
|||
if (!pos[1])
|
||||
{
|
||||
if (my_getopt_print_errors)
|
||||
report_option_error( reporter,
|
||||
reporter( ERROR_LEVEL,
|
||||
"%s: option '-%c' requires an argument\n",
|
||||
progname, optp->id);
|
||||
return EXIT_ARGUMENT_REQUIRED;
|
||||
|
|
@ -397,7 +387,7 @@ int handle_options(int *argc, char ***argv,
|
|||
}
|
||||
if ((error= setval(optp, argument, set_maximum_value)))
|
||||
{
|
||||
report_option_error( reporter,
|
||||
reporter( ERROR_LEVEL,
|
||||
"%s: Error while setting value '%s' to '%s'\n",
|
||||
progname, argument, optp->name);
|
||||
return error;
|
||||
|
|
@ -409,7 +399,7 @@ int handle_options(int *argc, char ***argv,
|
|||
if (!opt_found)
|
||||
{
|
||||
if (my_getopt_print_errors)
|
||||
report_option_error( reporter,
|
||||
reporter( ERROR_LEVEL,
|
||||
"%s: unknown option '-%c'\n", progname, *optend);
|
||||
return EXIT_UNKNOWN_OPTION;
|
||||
}
|
||||
|
|
@ -419,7 +409,7 @@ int handle_options(int *argc, char ***argv,
|
|||
}
|
||||
if ((error= setval(optp, argument, set_maximum_value)))
|
||||
{
|
||||
report_option_error( reporter,
|
||||
reporter( ERROR_LEVEL,
|
||||
"%s: Error while setting value '%s' to '%s'\n",
|
||||
progname, argument, optp->name);
|
||||
return error;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue