Fix that one cannot change value for deleted variables

This enasures that the 'variables that only exists for compatibility'
are always kept as its default value.

Based on an idea from Sergei Golubchik
This commit is contained in:
Monty 2024-04-21 14:29:31 +03:00 committed by Sergei Golubchik
parent 8af7a99443
commit 6254fcf84a
3 changed files with 8 additions and 6 deletions

View file

@ -133,6 +133,7 @@ double getopt_double_limit_value(double num, const struct my_option *optp,
ulonglong getopt_double2ulonglong(double); ulonglong getopt_double2ulonglong(double);
double getopt_ulonglong2double(ulonglong); double getopt_ulonglong2double(ulonglong);
void my_getopt_init_one_value(const struct my_option *, void *, longlong);
static inline void convert_underscore_to_dash(char *str, size_t len) static inline void convert_underscore_to_dash(char *str, size_t len)
{ {

View file

@ -36,7 +36,6 @@ static longlong getopt_ll(char *arg, const struct my_option *optp, int *err);
static ulonglong getopt_ull(char *, const struct my_option *, int *); static ulonglong getopt_ull(char *, const struct my_option *, int *);
static double getopt_double(char *arg, const struct my_option *optp, int *err); static double getopt_double(char *arg, const struct my_option *optp, int *err);
static void init_variables(const struct my_option *, init_func_p); static void init_variables(const struct my_option *, init_func_p);
static void init_one_value(const struct my_option *, void *, longlong);
static void fini_one_value(const struct my_option *, void *, longlong); static void fini_one_value(const struct my_option *, void *, longlong);
static int setval(const struct my_option *, void *, char *, my_bool, const char *); static int setval(const struct my_option *, void *, char *, my_bool, const char *);
static char *check_struct_option(char *cur_arg, char *key_name); static char *check_struct_option(char *cur_arg, char *key_name);
@ -278,7 +277,7 @@ int handle_options(int *argc, char ***argv, const struct my_option *longopts,
(*argc)--; /* Skip the program name */ (*argc)--; /* Skip the program name */
(*argv)++; /* --- || ---- */ (*argv)++; /* --- || ---- */
if (my_handle_options_init_variables) if (my_handle_options_init_variables)
init_variables(longopts, init_one_value); init_variables(longopts, my_getopt_init_one_value);
is_cmdline_arg= !is_file_marker(**argv); is_cmdline_arg= !is_file_marker(**argv);
@ -1381,13 +1380,13 @@ static double getopt_double(char *arg, const struct my_option *optp, int *err)
Init one value to it's default values Init one value to it's default values
SYNOPSIS SYNOPSIS
init_one_value() my_getopt_init_one_value()
option Option to initialize option Option to initialize
value Pointer to variable value Pointer to variable
*/ */
static void init_one_value(const struct my_option *option, void *variable, void my_getopt_init_one_value(const struct my_option *option, void *variable,
longlong value) longlong value)
{ {
DBUG_ENTER("init_one_value"); DBUG_ENTER("init_one_value");
switch ((option->var_type & GET_TYPE_MASK)) { switch ((option->var_type & GET_TYPE_MASK)) {
@ -1470,7 +1469,7 @@ static void init_one_value(const struct my_option *option, void *variable,
Init one value to it's default values Init one value to it's default values
SYNOPSIS SYNOPSIS
init_one_value() fini_one_value()
option Option to initialize option Option to initialize
value Pointer to variable value Pointer to variable
*/ */

View file

@ -8059,6 +8059,8 @@ mysqld_get_one_option(const struct my_option *opt, const char *argument,
case OPT_REMOVED_OPTION: case OPT_REMOVED_OPTION:
sql_print_warning("'%s' was removed. It does nothing now and exists only " sql_print_warning("'%s' was removed. It does nothing now and exists only "
"for compatibility with old my.cnf files.", opt->name); "for compatibility with old my.cnf files.", opt->name);
/* Restore default value (to show that the option cannot be used) */
my_getopt_init_one_value(opt, opt->value, opt->def_value);
break; break;
case OPT_MYSQL_COMPATIBILITY: case OPT_MYSQL_COMPATIBILITY:
sql_print_warning("'%s' is MySQL 5.6 / 5.7 compatible option. Not used or " sql_print_warning("'%s' is MySQL 5.6 / 5.7 compatible option. Not used or "