mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
MDEV-33469 Fix behavior on invalid arguments
When passing in an invalid value (e.g. incorrect data type) for a variable, the server startup will fail with misleading error messages. The behavior **before** this change: For server options: - The error message will indicate that the argument is being adjusted to a valid value - Server startup still fails For plugin options: - The error message will indicate that the argument is being adjusted to a valid value - The plugin is still disabled - Server startup fails with a message that it does not recognize the plugin option The behavior **after** this change: For server options: - Output that an invalid argument was provided - Exit server startup For plugin options: - Output that an invalid argument was provided - Disable the plugin - Attempt to continue server startup All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.
This commit is contained in:
parent
dd639985c1
commit
47d75cdd80
4 changed files with 13 additions and 3 deletions
|
@ -11,6 +11,8 @@ Test to see if multiple ambiguous options and invalid arguments will be displaye
|
|||
FOUND 1 /Error while setting value 'invalid_value' to 'sql_mode'/ in mysqltest.log
|
||||
FOUND 1 /ambiguous option '--character'/ in mysqltest.log
|
||||
FOUND 1 /option '--bootstrap' cannot take an argument/ in mysqltest.log
|
||||
FOUND 1 /Incorrect integer value: '18446744073709551616'/ in mysqltest.log
|
||||
FOUND 1 /Error while setting value '18446744073709551616' to 'binlog_cache_size'/ in mysqltest.log
|
||||
Test that --help --verbose works
|
||||
Test that --not-known-option --help --verbose gives error
|
||||
Done.
|
||||
|
|
|
@ -61,7 +61,7 @@ mkdir $MYSQLTEST_VARDIR/tmp/mysqld_option_err;
|
|||
|
||||
--echo Test to see if multiple ambiguous options and invalid arguments will be displayed in the error output
|
||||
--error 1
|
||||
--exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --getopt-prefix-matching --sql-mode=invalid_value --character --bootstrap=partstoob >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1
|
||||
--exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --getopt-prefix-matching --sql-mode=invalid_value --character --bootstrap=partstoob --binlog_cache_size=18446744073709551616 >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1
|
||||
|
||||
--let SEARCH_PATTERN=Error while setting value 'invalid_value' to 'sql_mode'
|
||||
--source include/search_pattern_in_file.inc
|
||||
|
@ -69,6 +69,10 @@ mkdir $MYSQLTEST_VARDIR/tmp/mysqld_option_err;
|
|||
--source include/search_pattern_in_file.inc
|
||||
--let SEARCH_PATTERN=option '--bootstrap' cannot take an argument
|
||||
--source include/search_pattern_in_file.inc
|
||||
--let SEARCH_PATTERN=Incorrect integer value: '18446744073709551616'
|
||||
--source include/search_pattern_in_file.inc
|
||||
--let SEARCH_PATTERN=Error while setting value '18446744073709551616' to 'binlog_cache_size'
|
||||
--source include/search_pattern_in_file.inc
|
||||
|
||||
#
|
||||
# Test that an wrong option with --help --verbose gives an error
|
||||
|
|
|
@ -133,7 +133,7 @@ double getopt_ulonglong2double(ulonglong v)
|
|||
return u.dbl;
|
||||
}
|
||||
|
||||
#define SET_HO_ERROR_AND_CONTINUE(e) { ho_error= (e); continue; }
|
||||
#define SET_HO_ERROR_AND_CONTINUE(e) { ho_error= (e); (*argc)--; continue; }
|
||||
|
||||
/**
|
||||
Handle command line options.
|
||||
|
@ -1077,6 +1077,8 @@ static ulonglong eval_num_suffix_ull(char *argument,
|
|||
static longlong getopt_ll(char *arg, const struct my_option *optp, int *err)
|
||||
{
|
||||
longlong num=eval_num_suffix_ll(arg, err, (char*) optp->name);
|
||||
if (*err)
|
||||
return(0);
|
||||
return getopt_ll_limit_value(num, optp, NULL);
|
||||
}
|
||||
|
||||
|
@ -1154,6 +1156,8 @@ longlong getopt_ll_limit_value(longlong num, const struct my_option *optp,
|
|||
static ulonglong getopt_ull(char *arg, const struct my_option *optp, int *err)
|
||||
{
|
||||
ulonglong num= eval_num_suffix_ull(arg, err, (char*) optp->name);
|
||||
if (*err)
|
||||
return(0);
|
||||
return getopt_ull_limit_value(num, optp, NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -4258,7 +4258,7 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp,
|
|||
|
||||
if (unlikely(error))
|
||||
{
|
||||
sql_print_error("Parsing options for plugin '%s' failed.",
|
||||
sql_print_error("Parsing options for plugin '%s' failed. Disabling plugin",
|
||||
tmp->name.str);
|
||||
goto err;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue