summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/mysqladmin.c10
-rw-r--r--libmysql/Makefile.shared3
-rw-r--r--mysys/my_getopt.c7
3 files changed, 17 insertions, 3 deletions
diff --git a/client/mysqladmin.c b/client/mysqladmin.c
index c5f8d653d82..7f6d1d1a85d 100644
--- a/client/mysqladmin.c
+++ b/client/mysqladmin.c
@@ -253,10 +253,16 @@ int main(int argc,char *argv[])
int error, ho_error;
MYSQL mysql;
char **commands;
+ char** save_argv;
MY_INIT(argv[0]);
mysql_init(&mysql);
load_defaults("my",load_default_groups,&argc,&argv);
-
+ save_argv = argv;
+ /* Sasha: with the change to handle_options() we now need to do this fix
+ with save_argv in all client utilities. The problem is that
+ handle_options may modify argv, and that wreaks havoc with
+ free_defaults()
+ */
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
{
printf("%s: handle_options() failed with error %d\n", my_progname,
@@ -327,7 +333,7 @@ int main(int argc,char *argv[])
}
my_free(opt_password,MYF(MY_ALLOW_ZERO_PTR));
my_free(user,MYF(MY_ALLOW_ZERO_PTR));
- free_defaults(argv);
+ free_defaults(save_argv);
my_end(0);
exit(error ? 1 : 0);
return 0;
diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared
index 0d3aa79b9ce..46be6103795 100644
--- a/libmysql/Makefile.shared
+++ b/libmysql/Makefile.shared
@@ -58,7 +58,8 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
my_compress.lo array.lo my_once.lo list.lo my_net.lo \
charset.lo hash.lo mf_iocache.lo \
mf_iocache2.lo my_seek.lo \
- my_pread.lo mf_cache.lo my_vsnprintf.lo md5.lo
+ my_pread.lo mf_cache.lo my_vsnprintf.lo md5.lo \
+ my_getopt.lo
# Not needed in the minimum library
mysysobjects2 = getopt.lo getopt1.lo getvar.lo my_lib.lo
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index 0b24e77bca3..b17d1463121 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -102,6 +102,12 @@ int handle_options(int *argc, char ***argv,
cur_arg= *pos;
(*argc)--;
}
+ /* Sasha: quick dirty fix of a bug that coredumps mysqladmin while
+ running the test suite. The bug is actually pretty serious -
+ even in cases when we do not coredump, -O var=val will not set
+ the variable, and the previous option would be treated upredictably.
+ */
+ goto found_var;
}
else if (*cur_arg == '-') /* check for long option, or --set-variable */
{
@@ -145,6 +151,7 @@ int handle_options(int *argc, char ***argv,
continue;
}
}
+ found_var:
optend= strcend(cur_arg, '=');
length= optend - cur_arg;
if (*optend == '=')