Bug #68800 client doesn't read plugin-dir from my.cnf set by MYSQL_READ_DEFAULT_FILE
Submitted: 27 Mar 2013 19:59 Modified: 24 Apr 2013 15:17
Reporter: Sergei Glushchenko (OCA) Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: C API (client library) Severity:S3 (Non-critical)
Version:5.5.30, 5.6+ OS:Any
Assigned to: CPU Architecture:Any

[27 Mar 2013 19:59] Sergei Glushchenko
Assuming this is set on my.cnf:


Client library is forced to read from it with:

 MYSQL* res = mysql_init(con);
 mysql_options(res, MYSQL_READ_DEFAULT_FILE, "/path/to/my.cnf");

plugin-dir setting does not have effect.

Looks like invocation of convert_dirname is incorrect in following code (client.c)

case OPT_plugin_dir:
    char buff[FN_REFLEN], buff2[FN_REFLEN];
    if (strlen(opt_arg) >= FN_REFLEN)
      opt_arg[FN_REFLEN]= '\0';
    if (my_realpath(buff, opt_arg, 0))
      DBUG_PRINT("warning",("failed to normalize the plugin path: %s",
    convert_dirname(buff, buff2, NULL);
    EXTENSION_SET_STRING(options, plugin_dir, buff2);

How to repeat:
Read the description
[29 Mar 2013 19:10] Sinisa Milivojevic
Sorry, in which version did you notice this problem ???
[1 Apr 2013 4:50] Sergei Glushchenko
Hello Sinisa,

5.5.30 as well as 5.6.10
[16 Apr 2013 16:18] Sinisa Milivojevic
I will check this thoroughly, but meanwhile, can you check whether your plugin-dir has privileges that would allow the user under which you run mysql CLI in your shell (or command prompt) to read the config file..

Thanks in advance.
[16 Apr 2013 20:13] Sergei Glushchenko
Yes, I'm absolutely sure that permissions are OK.
The problem is not in CLI client (mysql). CLI works just fine. The problem is in client library (libmysqlclient) when one trying to pass the path to my.cnf with API call

mysql_options(res, MYSQL_READ_DEFAULT_FILE, "/path/to/my.cnf");

You can also look at the code which I cited and make sure that correct order of arguments for convert_dirname should be convert_dirname(to, from, from_end), however in that place it is  convert_dirname(buff /*from*/, buff2 /*to*/, NULL /*from_end*/);. As a result there is a lot of garbage in buff2 instead of correct path.
[17 Apr 2013 16:07] Sinisa Milivojevic
I have verified this bug by debugging the code. Which also made me discover how to fix it.

I can only post a provisional fix. Development is the only entity that can confirm or negate the fix. Not to mention a fact that any fix has also to pass a number of steps in testing and quality control before it becomes official. Hence, the only official patches are the ones in the releases. This is only a provisional patch !!!

This is a fix that relates ONLY to the settings of the `plugin_dir` field in the `extension` structure within options. I did not follow AT ALL whether loading of plugins really works or not, as I did not create nor copy any plugins in the new plugins directory. After a fix, `plugin_dir` field held a correct value.

A patch is actually very trivial and is a small mistake of programmer, because `to` and `from` parameters were mixed in `convert_dirname` function call. Here it is:

*** tmp/client.c        Wed Apr 17 18:31:41 2013
--- sql-common/client.c Wed Apr 17 18:22:48 2013
*** 1302,1308 ****
!             convert_dirname(buff, buff2, NULL);
              EXTENSION_SET_STRING(options, plugin_dir, buff2);
--- 1302,1308 ----
!             convert_dirname(buff2, buff, NULL);
              EXTENSION_SET_STRING(options, plugin_dir, buff2);
[24 Apr 2013 15:17] Paul Dubois
Noted in 5.5.32, 5.6.12, 5.7.2 changelogs.

When specified in an option file, the plugin-dir client option was
[6 Jun 2013 15:49] Laurynas Biveinis
For some reason the public bug db bug id is missing from the commit message.

Also it's very interesting that the fix idea is not acknowledged to Sergei, who kindly provided it in the Apr 16th comment... :)

5.6$ bzr log -r 5040 -n0
revno: 5040 [merge]
committer: Georgi Kodinov <georgi.kodinov@oracle.com>
branch nick: B16680313-5.6
timestamp: Wed 2013-04-24 17:24:06 +0300
  merge 5.5->5.6
    revno: 2875.437.78
    committer: Georgi Kodinov <georgi.kodinov@oracle.com>
    branch nick: B16680313-5.5
    timestamp: Wed 2013-04-24 17:21:42 +0300
      Parsing of the plugin-dir config file option was not working due to a typo.
      Fixed the typo. No test case can be added due to lack of support for 
      defaults-exitra-file testing in mysql-test-run.pl.
      Thanks to Sinisa for contributing the fix.