[MDEV-21374] When "--help --verbose" prints out configuration file paths, the --defaults-file option is not considered Created: 2019-12-20  Updated: 2020-03-31  Resolved: 2020-02-22

Status: Closed
Project: MariaDB Server
Component/s: Configuration, Scripts & Clients
Affects Version/s: 10.2.29, 10.1.43, 10.3.20, 10.4.11
Fix Version/s: 10.1.45, 10.2.32, 10.3.23, 10.4.13, 10.5.2

Type: Bug Priority: Major
Reporter: Geoff Montee (Inactive) Assignee: Anel Husakovic
Resolution: Fixed Votes: 0
Labels: None


 Description   

mysqld and other utilities support the --help --verbose parameters. When these parameters are set, the utility will print out the configuration files that it reads:

$ mysqld --help --verbose
...
Default options are read from the following files in the given order:
/etc/my.cnf ~/.my.cnf
...

https://mariadb.com/kb/en/library/configuring-mariadb-with-option-files/#default-option-file-locations

The default paths for configuration files can be overridden by using the --defaults-file option.

https://mariadb.com/kb/en/library/configuring-mariadb-with-option-files/#custom-option-file-locations

However, the --help --verbose parameters do not seem to take this option into account when printing configuration file paths:

$ mysqld --defaults-file=/tmp/my.cnf --help --verbose
...
Default options are read from the following files in the given order:
/etc/my.cnf ~/.my.cnf
...



 Comments   
Comment by Anel Husakovic [ 2019-12-21 ]

So your point is if --defaults-file= =/tmp/my.cnf is supplied than output should be dynamically changed (or appended to previous /etc/my.cnf ~/.my.cnf):

Default options are read from the following files in the given order:
/tmp/my.cnf

right ?
In this situation we should check defaults-file (extra_opt variable ?) and if exist conf_file should be changed from MYSQL_CONFIG_NAME to argument of defaults-file in function print_defaults().

Isn't the current situation self explanatory?
Meaning, rule of thumb are default options in given order + bellow there is option --default-file which is explaining what it should do, if one would like to use it.
Than those will not be default options, but custom options.

Comment by Geoff Montee (Inactive) [ 2019-12-21 ]

Hi anel,

So your point is if --defaults-file= =/tmp/my.cnf is supplied than output should be dynamically changed ?

Yes, exactly. The output is already changed dynamically in several cases. We just need to fix it so that it is also changed dynamically in the case that the --defaults-file option is set.

For example, here's normal output:

$ mysql --help --verbose
...
Default options are read from the following files in the given order:
/etc/my.cnf ~/.my.cnf

And if you set the --defaults-extra-file option, then the output changes to this:

$ mysql --defaults-extra-file=/etc/my_extra.cnf --help --verbose
...
Default options are read from the following files in the given order:
/etc/my.cnf /etc/my_extra.cnf/my.cnf ~/.my.cnf

And if you set the $MYSQL_HOME environment variable, then the output changes to this:

$ export MYSQL_HOME=/mysql
$ mysql --help --verbose
...
Default options are read from the following files in the given order:
/etc/my.cnf /mysql/my.cnf ~/.my.cnf

Comment by Geoff Montee (Inactive) [ 2019-12-21 ]

Additionally, the -help --verbose output also changes if the -defaults-group-suffix option is set:

$ mysql --defaults-group-suffix=_server1 --help --verbose
...
The following groups are read: mysql mariadb-client client client-server client-mariadb mysql_server1 mariadb-client_server1 client_server1 client-server_server1 client-mariadb_server1
...

And the output also changes if the $MYSQL_GROUP_SUFFIX environment variable is set:

$ export MYSQL_GROUP_SUFFIX=_server1
$ mysql --help --verbose
...
The following groups are read: mysql mariadb-client client client-server client-mariadb mysql_server1 mariadb-client_server1 client_server1 client-server_server1 client-mariadb_server1
...

Comment by Anel Husakovic [ 2019-12-27 ]

Hi GeoffMontee,
thanks, I think it is good idea to show only the file which is used in case defaults-file without appending to other global configs.
What about no-defaults only, I think we should probably change the message here too saying that there is no supplied config file in help verbose?!

Comment by Geoff Montee (Inactive) [ 2019-12-27 ]

Hi anel,

That kind of change in behavior sounds like it would make it consistent to me.

Comment by Anel Husakovic [ 2019-12-31 ]

Hi GeoffMontee,
after the patch is applied here are the outputs:

$ ./sql/mysqld --defaults-file=/home/anel/my_10.1.cnf --help --verbose | less
 
Default options are read from the following files in the given order:
/home/anel/my_10.1.cnf

Also the patch is fixing case for defaults-file-extra, where the file is translated to directory and my.cnf is appended, so it was:

$ ./sql/mysqld --defaults-extra-file=/home/anel/my_10.1.cnf --help --verbose | less
 
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /home/anel/my_10.1.cnf/my.cnf ~/.my.cnf 
 
# With patch we are just using file name:
# Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /home/anel/my_10.1.cnf ~/.my.cnf 

right?
For --no-format , there is no variable defined for that, except that we now it has to be first in queue to have a impact and a lot of prototypes should be changed, so I didn't want to change that.

Comment by Geoff Montee (Inactive) [ 2019-12-31 ]

Hi anel,

Looks good to me!

Comment by Vicențiu Ciorbaru [ 2020-02-22 ]

Ok to push

Comment by Anel Husakovic [ 2020-02-22 ]

Pushed with b9689712e

Generated at Thu Feb 08 09:06:39 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.