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);
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)
{

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 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_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 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 */
(*argv)++; /* --- || ---- */
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);
@ -1381,12 +1380,12 @@ static double getopt_double(char *arg, const struct my_option *optp, int *err)
Init one value to it's default values
SYNOPSIS
init_one_value()
my_getopt_init_one_value()
option Option to initialize
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)
{
DBUG_ENTER("init_one_value");
@ -1470,7 +1469,7 @@ static void init_one_value(const struct my_option *option, void *variable,
Init one value to it's default values
SYNOPSIS
init_one_value()
fini_one_value()
option Option to initialize
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:
sql_print_warning("'%s' was removed. It does nothing now and exists only "
"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;
case OPT_MYSQL_COMPATIBILITY:
sql_print_warning("'%s' is MySQL 5.6 / 5.7 compatible option. Not used or "