diff options
author | Anel Husakovic <anel@mariadb.org> | 2019-12-31 18:02:54 +0100 |
---|---|---|
committer | Anel Husakovic <anel@mariadb.org> | 2020-02-22 22:46:58 +0100 |
commit | b9689712e00bec64fa5dfad7ed65e6a82df8be23 (patch) | |
tree | b078fa321cdc46b237268f7a29ec434bd0755509 | |
parent | 716161ea03c5018f308017dd9279731a322e26bc (diff) | |
download | mariadb-git-b9689712e00bec64fa5dfad7ed65e6a82df8be23.tar.gz |
MDEV-21374: When "--help --verbose" prints out configuration file paths, the --defaults-file option is not considered
* `--defaults-file` option is showed only in `--help --verbose` if
applied
* `--default-extra-file` is showing correctly now in `--help --verbose`,
previously it was treated as a directory with appended `my.cnf`
-rw-r--r-- | mysql-test/r/mysqld--defaults-file.result | 12 | ||||
-rw-r--r-- | mysql-test/t/mysqld--defaults-file.test | 16 | ||||
-rw-r--r-- | mysys/my_default.c | 10 |
3 files changed, 38 insertions, 0 deletions
diff --git a/mysql-test/r/mysqld--defaults-file.result b/mysql-test/r/mysqld--defaults-file.result index 5fd5ca8d95a..be62580c47e 100644 --- a/mysql-test/r/mysqld--defaults-file.result +++ b/mysql-test/r/mysqld--defaults-file.result @@ -10,3 +10,15 @@ Could not open required defaults file: MYSQL_TEST_DIR/with.ext Fatal error in defaults handling. Program aborted Could not open required defaults file: MYSQL_TEST_DIR/no_extension Fatal error in defaults handling. Program aborted +# +# MDEV-21374: When "--help --verbose" prints out configuration file paths, +# the --defaults-file option is not considered +# +# Test on `defaults-file` +Default options are read from the following files in the given order: +MYSQLTEST_VARDIR/my.cnf +The following groups are read: mysqld server mysqld-10.1 mariadb mariadb-10.1 client-server galera +# Test on `defaults-extra-file` +Default options are read from the following files in the given order: +<first-defaults> MYSQLTEST_VARDIR/my_test.cnf ~/.my.cnf +The following groups are read: mysqld server mysqld-10.1 mariadb mariadb-10.1 client-server galera diff --git a/mysql-test/t/mysqld--defaults-file.test b/mysql-test/t/mysqld--defaults-file.test index 3bfe0aa891f..acc1cea5b8c 100644 --- a/mysql-test/t/mysqld--defaults-file.test +++ b/mysql-test/t/mysqld--defaults-file.test @@ -29,3 +29,19 @@ exec $MYSQLD --defaults-file=with.ext --print-defaults 2>&1; --error 1 exec $MYSQLD --defaults-file=no_extension --print-defaults 2>&1; +--echo # +--echo # MDEV-21374: When "--help --verbose" prints out configuration file paths, +--echo # the --defaults-file option is not considered +--echo # + +--echo # Test on `defaults-file` +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +exec $MYSQLD --defaults-file=$MYSQLTEST_VARDIR/my.cnf --help --verbose | grep -A 2 'Default options are read'; + +--echo # Test on `defaults-extra-file` +# <first-defaults> = `/etc/my.cnf /etc/mysql/my.cnf` +# Using sysconfdir configuration, we don't always have `/etc/mysql/my.cnf`, so replace them with a regex as well. +copy_file $MYSQLTEST_VARDIR/my.cnf $MYSQLTEST_VARDIR/my_test.cnf; +--replace_regex /.*my_test.cnf/<first-defaults> MYSQLTEST_VARDIR\/my_test.cnf/ +exec $MYSQLD --defaults-extra-file=$MYSQLTEST_VARDIR/my_test.cnf --help --verbose | grep -A 2 'Default options are read'; +remove_file $MYSQLTEST_VARDIR/my_test.cnf; diff --git a/mysys/my_default.c b/mysys/my_default.c index 32faf2045f9..6f080bb35fe 100644 --- a/mysys/my_default.c +++ b/mysys/my_default.c @@ -1035,6 +1035,11 @@ void my_print_default_files(const char *conf_file) char name[FN_REFLEN], **ext; puts("\nDefault options are read from the following files in the given order:"); + if (my_defaults_file) + { + puts(my_defaults_file); + return; + } if (dirname_length(conf_file)) fputs(conf_file,stdout); @@ -1059,7 +1064,12 @@ void my_print_default_files(const char *conf_file) if (**dirs) pos= *dirs; else if (my_defaults_extra_file) + { pos= my_defaults_extra_file; + fputs(pos, stdout); + fputs(" ", stdout); + continue; + } else continue; end= convert_dirname(name, pos, NullS); |