Commit 0805cdeb authored by Rucha Deodhar's avatar Rucha Deodhar

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().
parent e9ffed07
...@@ -141,28 +141,50 @@ static int get_options(int *argc,char ***argv) ...@@ -141,28 +141,50 @@ static int get_options(int *argc,char ***argv)
return 0; 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 main(int argc, char **argv)
{ {
int count, error, args_used; int count= 0, error, no_defaults= 0;
char **load_default_groups= 0, *tmp_arguments[6]; char **load_default_groups= 0, *tmp_arguments[6];
char **argument, **arguments, **org_argv; char **argument, **arguments, **org_argv;
int nargs, i= 0; int nargs, i= 0;
MY_INIT(argv[0]); MY_INIT(argv[0]);
org_argv= argv; org_argv= argv;
args_used= get_defaults_options(argv); if (*argv && !strcmp(*argv, "--no-defaults"))
{
/* Copy defaults-xxx arguments & program name */ argv++;
count=args_used; ++count;
no_defaults= 1;
}
/* Copy program name and --no-defaults if present*/
arguments= tmp_arguments; arguments= tmp_arguments;
memcpy((char*) arguments, (char*) org_argv, count * sizeof(*org_argv)); memcpy((char*) arguments, (char*) org_argv, (++count)*sizeof(*org_argv));
arguments[count]= 0; arguments[count]= 0;
/* Check out the args */ /* Check out the args */
if (get_options(&argc,&argv)) if (get_options(&argc,&argv))
cleanup_and_exit(1); cleanup_and_exit(1);
if (!no_defaults)
{
if (opt_defaults_file_used)
arguments[count++]= make_args("--defaults-file=", config_file);
if (my_defaults_extra_file)
arguments[count++]= make_args("--defaults-extra-file=",
my_defaults_extra_file);
if (my_defaults_group_suffix)
arguments[count++]= make_args("--defaults-group-suffix=",
my_defaults_group_suffix);
arguments[count]= 0;
}
nargs= argc + 1; nargs= argc + 1;
if (opt_mysqld) if (opt_mysqld)
nargs+= array_elements(mysqld_groups); nargs+= array_elements(mysqld_groups);
......
...@@ -11,3 +11,41 @@ ...@@ -11,3 +11,41 @@
--max_connections=1024 --max_connections=1024
--long_query_time=60 --long_query_time=60
--slow_query_log=1 --slow_query_log=1
#
# MDEV-25908: -e does not work for my_print_defaults
#
# Testing -e
--key_buffer_size=20M
--max_allowed_packet=250M
--table_open_cache=1000
#Testing --defaults-extra-file
--key_buffer_size=20M
--max_allowed_packet=250M
--table_open_cache=1000
#
# Testing other options
#
# Testing -c option
--key_buffer_size=20M
--max_allowed_packet=250M
--table_open_cache=1000
# Testing --defaults-file
--key_buffer_size=20M
--max_allowed_packet=250M
--table_open_cache=1000
# Testing -g option
--key_buffer_size=20M
--max_allowed_packet=250M
--table_open_cache=1000
--table_definition_cache=2000
--read_buffer_size=1M
--thread_cache_size=8
# Testing --defaults-group-suffix
--key_buffer_size=20M
--max_allowed_packet=250M
--table_open_cache=1000
--table_definition_cache=2000
--read_buffer_size=1M
--thread_cache_size=8
# Testing --no-defaults
# End of 10.5 Test
...@@ -30,7 +30,77 @@ long_query_time=60 ...@@ -30,7 +30,77 @@ long_query_time=60
slow_query_log=1 slow_query_log=1
EOF EOF
--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-extra-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf -c $MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf
--echo #
--echo # MDEV-25908: -e does not work for my_print_defaults
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
[mariadb]
key_buffer_size=20M
max_allowed_packet=250M
table_open_cache=1000
EOF
--write_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf
[mariadb]
key_buffer_size=20M
max_allowed_packet=250M
table_open_cache=1000
EOF
--echo # Testing -e
--exec $MYSQL_MY_PRINT_DEFAULTS -e $MYSQLTEST_VARDIR/tmp/tmp1.cnf -c $MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server
--echo #Testing --defaults-extra-file
--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-extra-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf -c $MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server --exec $MYSQL_MY_PRINT_DEFAULTS --defaults-extra-file=$MYSQLTEST_VARDIR/tmp/tmp1.cnf -c $MYSQLTEST_VARDIR/tmp/tmp2.cnf --mysqld mysql.server
--remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf --remove_file $MYSQLTEST_VARDIR/tmp/tmp1.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf --remove_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf
--echo #
--echo # Testing other options
--echo #
--write_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf
[mariadb]
key_buffer_size=20M
max_allowed_packet=250M
table_open_cache=1000
EOF
--write_file $MYSQLTEST_VARDIR/tmp/tmp3.cnf
[mariadb]
key_buffer_size=20M
max_allowed_packet=250M
table_open_cache=1000
[mariadb.1]
table_definition_cache=2000
read_buffer_size=1M
thread_cache_size=8
EOF
--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
--echo # Testing --no-defaults
--exec $MYSQL_MY_PRINT_DEFAULTS --no-defaults
--remove_file $MYSQLTEST_VARDIR/tmp/tmp2.cnf
--remove_file $MYSQLTEST_VARDIR/tmp/tmp3.cnf
--echo # End of 10.5 Test
...@@ -2688,6 +2688,7 @@ DROP TABLE t1, t2; ...@@ -2688,6 +2688,7 @@ DROP TABLE t1, t2;
# (Problems with --defaults-extra-file option) # (Problems with --defaults-extra-file option)
# #
--port=1234 --port=1234
--port=1234
# #
# Test of fix to Bug#12597 mysqldump dumps triggers wrongly # Test of fix to Bug#12597 mysqldump dumps triggers wrongly
# #
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment