Bug #58109 Function my_load_defaults() does not read correct file
Submitted: 10 Nov 2010 11:42 Modified: 14 Dec 2010 23:27
Reporter: Mats Kindahl Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Options Severity:S3 (Non-critical)
Version:5.6 OS:Any
Assigned to: Mats Kindahl CPU Architecture:Any

[10 Nov 2010 11:42] Mats Kindahl
Description:
According to the comments for my_load_defaults():

    /*
      ...
      conf_file			Basename for configuration file to search for.
      				If this is a path, then only this file is read.
      ...
    */
  int my_load_defaults(const char *conf_file, const char **groups, ...

But inside the my_search_option_files function, the following order of checks are done:

  if (my_defaults_file)
  {
    ...
  }
  else if (dirname_length(conf_file))
  {
     ...

Meaning that even when an absolute path is provided, it searches the previously discovered defaults file. This will cause problems if a specific configuration file is going to be read after the "real" defaults file (which is how WL#4677 persist a generated UUID for the server: by writing a separate configuration file with the information).

How to repeat:
Read the code.

Suggested fix:
Change the order of the conditionals so that the dirname_length() call is first. This will ensure that if an absolute file name is given, it is read.
[10 Nov 2010 11:48] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/123396

3330 Mats Kindahl	2010-11-10
      Bug #58109: Function my_load_defaults() does not read
                  correct file
      
      When passed an absolute filename, my_load_defaults()
      is supposed to read only that file, but instead it
      reads values from the defaults file found in a previous
      execution of the function (which is saved in
      my_defaults_file).
      
      This patch fixes this by changing order of checks in
      my_search_option_files() so that it first checks if an
      absolute path was supplied, and in that case uses that
      file only.
[13 Nov 2010 16:15] Bugs System
Pushed into mysql-trunk 5.6.99-m5 (revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (version source revid:alexander.nozdrin@oracle.com-20101113152450-2zzcm50e7i4j35v7) (merge vers: 5.6.1-m4) (pib:21)
[13 Nov 2010 16:41] Bugs System
Pushed into mysql-next-mr (revid:alexander.nozdrin@oracle.com-20101113160336-atmtmfb3mzm4pz4i) (version source revid:alexander.nozdrin@oracle.com-20101113152540-gxro4g0v29l27f5x) (pib:21)
[14 Dec 2010 23:27] Paul DuBois
Bug is not present in any released 5.6.x version.