On 09/25/2016 02:21 AM, Wietse Venema wrote: > Wietse: > Summary > ======= > I think I found a libmysqlclient bug. According to documentation: > > The [client] option group is read by all client programs (but > not by mysqld). This enables you to specify options that apply > to all clients. > > I suspect that by client programs they intend these ones:
http://dev.mysql.com/doc/refman/5.7/en/programs-client.html or namely the ones delivered with MySQL. If so the MySQL documentation could be made clearer, though it is worth noting that this phrase occurs in the manual section that describes the MySQL provided server and client programs. > is what your patch does. > > The code suggests that the library reads the "client" options group > and any group that was specified by the application (Postfix). But > mysql_read_default_options() is never called unless the application > has called mysql_options() with an options file name or options > group name. Otherwise it would not even read the client options > group, in contradiction with the documentation. > > Wietse The documentation is clearer about the observed behaviour when you read the specific documentation for the C API: http://dev.mysql.com/doc/refman/5.7/en/mysql-options.html "The |client| group is always read if you use | MYSQL_READ_DEFAULT_FILE| or |MYSQL_READ_DEFAULT_GROUP|." I wondered what the reason was for NOT reading the client group when you don't set one of these and I came to the conclusion that it was intended behaviour. There may be circumstances in which you do not want to read default options files (the equivalent of the --no-defaults <http://dev.mysql.com/doc/refman/5.7/en/mysql-command-options.html#option_mysql_no-defaults> command line option in mysql client programs). You could argue that this was not the best way to do it, but my guess is that the code is working as it was intended and that the mysql documentation needs a few more lines of clarity. This can be further investigated on the MySQL lists. I am willing to do that. Before submitting the Postfix patch I had checked how Dovecot was doing this (since during my testing I noticed that Dovecot was also reading the [client] section - it was running my init-command sql). Their code is: mysql_options(db->mysql, MYSQL_READ_DEFAULT_GROUP, db->option_group != NULL ? db->option_group : "client"); from dovecot-2.2.24/src/lib-sql/driver-mysql.c basically the equivalent of my proposed patch to Postfix. This is the original commit from 2008 when the functionality was first introduced: https://github.com/dovecot/core/commit/c87d1e148ae76cf20f3adc7fc84fd54219dc62d5 I think for Postfix there are two potential ways to deal with the MySQL behaviour: either 1) go with the proposed patch or 2) update the Postfix documentation to indicate that (as per MySQL functionality) no defaults are read unless at least option_file or option_group is set and leave it to the user to chose what they want. If you go with the patch and there is concern about breaking people's existing configurations (maybe unlikely but certainly possible). Then the new behaviour could be introduced as a backwards incompatible change that must be explicitly turned on in existing installations. John