[CONC-396] !includedir in my.cnf does not include all .cnf and .ini files in the directory Created: 2019-03-23  Updated: 2020-06-28

Status: Open
Project: MariaDB Connector/C
Component/s: None
Affects Version/s: 3.0.8
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Geoff Montee (Inactive) Assignee: Georg Richter
Resolution: Unresolved Votes: 1
Labels: None

Issue Links:
Blocks
blocks MDEV-19035 Make MariaDB Connector/C handle my.cn... Open
Relates
relates to CONC-402 Replace underscores with dashes in co... Closed
relates to CONC-404 Add option that corresponds to --defa... Open
relates to CONC-327 !include/!includedir not parsed in my... Closed
relates to CONC-394 Some TLS-related options are not sett... Closed
relates to CONC-395 Dashes and underscores are not interc... Closed
relates to CONC-399 Add option that corresponds to --defa... Open
relates to CONC-415 Option prefixes not supported in my.cnf Open
relates to CONC-416 On Windows, C/C looks for first my.cn... Closed
relates to ODBC-229 Add parameters that correspond to MYS... Closed

 Description   

When the server parses my.cnf or other option/configuration files, it interprets the !includedir directive to mean that it should include all .cnf and .ini files in the directory:

It is also possible to include all option files in a directory from another option file. For example, to include all option files in /etc/my.cnf.d/, an option file could contain:

[mariadb]
...
!includedir /etc/my.cnf.d/

The option files within the directory are read in alphabetical order.

All option file names must end in .cnf on Unix-like operating systems. On Windows, all option file names must end in .cnf or .ini.

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

This is not the case with MariaDB Connector/C:

It is also possible to include the default option files in a directory from another option file. For example, to include the default option files in /etc/my.cnf.d/, an option file could contain:

[client-mariadb]
...
!includedir /etc/my.cnf.d/

Unlike with MariaDB server, this directive does not configure MariaDB Connector/C to include all option files ending in .cnf on Unix-like operating systems or all option files ending in .cnf and .ini files on Windows. Instead, it just configures MariaDB Connector/C to include the my.cnf in the given directory, and also the my.ini in the given directory if it's Windows.

https://mariadb.com/kb/en/library/configuring-mariadb-connectorc-with-option-files/#including-option-file-directories

This can be seen here:

https://github.com/MariaDB/mariadb-connector-c/blob/1285dc72a043f09d9a51abcfc3a4fbfb5192067e/libmariadb/ma_default.c#L196

https://github.com/MariaDB/mariadb-connector-c/blob/1285dc72a043f09d9a51abcfc3a4fbfb5192067e/libmariadb/ma_default.c#L328

We might want to change this, so that it reads all .cnf and .ini files in the directory, so that MariaDB Connector/C handles !includedir more like MariaDB Server.



 Comments   
Comment by Sergei Golubchik [ 2019-03-24 ]

I agree, it should behave as in the server

Comment by Samuel Williams [ 2020-06-28 ]

I ran into this issue when using GitHub actions and `libmariadb`.

In particular, it turns out that they mysql installation uses a socket which I had to set explicitly:

https://github.com/socketry/db-mysql/commit/5e9e97f31dc3e553ab8f87d9e879d4ec4a65f66a

The socket path is described in a configuration file but it isn't loaded by `libmariadb`.

The top level config `/etc/mysql/my.cnf`:

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

Then in `/etc/mysql/mysql.conf.d/mysqld.cnf`:

[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock

But the setting is not picked up correctly and thus the connection fails without the explicit environment variable being set.

Generated at Thu Feb 08 03:05:01 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.