Re: [Maria-developers] 70252733d41: MDEV-25908: -e does not work for my_print_defaults
Hi, Rucha! On Jul 15, Rucha Deodhar wrote:
revision-id: 70252733d41 (mariadb-10.5.11-35-g70252733d41) parent(s): f88d130e710 author: Rucha Deodhar <rucha.deodhar@mariadb.com> committer: Rucha Deodhar <rucha.deodhar@mariadb.com> timestamp: 2021-07-14 22:55:21 +0530 message:
MDEV-25908: -e does not work for my_print_defaults
Analysis: get_defaults_options() rewrites the value for my_defaults_file, my_defaults_extra_file and my_defaults_group_suffix to 0. So the config file can't be read. Fix: Let handle_options() handle --defaults* option and create a new command line to pass it to load_defaults().
--- extra/my_print_defaults.c | 37 +++++++++++++++++----- mysql-test/main/my_print_defaults.result | 35 ++++++++++++++++++++- mysql-test/main/my_print_defaults.test | 54 +++++++++++++++++++++++++++++++- mysql-test/main/mysqldump.result | 1 + 4 files changed, 117 insertions(+), 10 deletions(-)
diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c index 1dec667949f..409ef273b44 100644 --- a/extra/my_print_defaults.c +++ b/extra/my_print_defaults.c @@ -141,28 +141,49 @@ static int get_options(int *argc,char ***argv) return 0; }
+static char *make_args(const char *s1, const char *s2) +{ + char *s= malloc(strlen(s1) + strlen(s2) + 1); + strmov(strmov(s, s1), s2); + return s; +}
int main(int argc, char **argv) { - int count, error, args_used; - char **load_default_groups= 0, *tmp_arguments[6]; + int count= 0, error, no_defaults= 0; + char **load_default_groups= 0; char **argument, **arguments, **org_argv; int nargs, i= 0; MY_INIT(argv[0]);
org_argv= argv; - args_used= get_defaults_options(argv); - - /* Copy defaults-xxx arguments & program name */ - count=args_used; - arguments= tmp_arguments; - memcpy((char*) arguments, (char*) org_argv, count * sizeof(*org_argv)); + if (*argv && !strcmp(*argv, "--no-defaults")) + { + argv++; + ++count; + no_defaults= 1; + } + /* Copy program name and --no-defaults if present*/ + memcpy((char*) arguments, (char*) org_argv, (++count)*sizeof(*org_argv));
isn't this wrong? `arguments` is uninitialized at this point.
arguments[count]= 0;
/* Check out the args */ if (get_options(&argc,&argv)) cleanup_and_exit(1);
+--echo # Testing -e +--exec $MYSQL_MY_PRINT_DEFAULTS -e $MYSQLTEST_VARDIR/tmp/tmp1.cnf --mysqld mysql.server +--echo #Testing --defaults-extra-file +--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-extra-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf --mysqld mysql.server + +--echo # Testing -c option +--exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server +--echo # Testing --defaults-file +--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-file=$MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server + +--echo # Testing -g option +--exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQLTEST_VARDIR/tmp/tmp3.cnf --mysqld mysql.server -g .1 +--echo # Testing --defaults-group-suffix +--exec $MYSQL_MY_PRINT_DEFAULTS -c $MYSQLTEST_VARDIR/tmp/tmp3.cnf --mysqld mysql.server --defaults-group-suffix=.1
you don't seem have a --no-defaults test Regards, Sergei VP of MariaDB Server Engineering and security@mariadb.org
participants (1)
-
Sergei Golubchik