[ODBC-229] Add parameters that correspond to MYSQL_READ_DEFAULT_FILE and MYSQL_READ_DEFAULT_GROUP options from MariaDB Connector/C Created: 2019-03-07  Updated: 2020-08-25  Resolved: 2019-03-19

Status: Closed
Project: MariaDB Connector/ODBC
Component/s: General
Affects Version/s: 3.1.0, 3.0.8
Fix Version/s: 2.0.19, 3.0.9, 3.1.1

Type: Task Priority: Major
Reporter: Geoff Montee (Inactive) Assignee: Lawrin Novitsky
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to CONC-327 !include/!includedir not parsed in my... Closed
relates to CONC-395 Dashes and underscores are not interc... Closed
relates to CONC-396 !includedir in my.cnf does not includ... Open
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-394 Some TLS-related options are not sett... 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

 Description   

MariaDB Connector/C allows an application to read a MariaDB configuration file, and it also allows the application to specify the option group within the configuration file. The MYSQL_READ_DEFAULT_FILE and MYSQL_READ_DEFAULT_GROUP options are used for this:

MYSQL_READ_DEFAULT_FILE:

MYSQL_READ_DEFAULT_FILE: Read options from named option or my.cnf. To read from the my.cnf file a NULL pointer has to be passed instead of a file name.

mysql_optionsv(mysql, MYSQL_READ_DEFAULT_FILE, (void *)"./my_conf.cnf");

MariaDB Connector/C will not read the configuration by default. If MYSQL_READ_DEFAULT_FILE is specified the following sections will be always processed:

[client]
[client-server]
[client-mariadb]

MYSQL_READ_DEFAULT_GROUP:

MYSQL_READ_DEFAULT_GROUP: Read options from the named group from my.cnf or the file specified with MYSQL_READ_DEFAULT_FILE.

mysql_optionsv(mysql, MYSQL_READ_DEFAULT_GROUP, (void *)"my_section");

https://mariadb.com/kb/en/library/mysql_optionsv/#options

It might be useful if MariaDB Connector/ODBC allowed users to configure an ODBC data source to read options from a configuration file.



 Comments   
Comment by Lawrin Novitsky [ 2019-03-19 ]

Wouldn't it be enough to do like mysql's connector does - the connection option enables or disables read from the default section([odbc]) of the default file(my.cnf). I'd do it this way

Comment by Geoff Montee (Inactive) [ 2019-03-19 ]

Hi Lawrin,

I personally like the flexibility to set the path to the configuration file, but it's probably enough for most users to read from the default my.cnf.

Reading options from the [odbc] option group sounds good. It would also still read options from the default client option groups, right? e.g. [client], [client-server], [client-mariadb]

Comment by Lawrin Novitsky [ 2019-03-19 ]

Pushed to odbc-3.0 as 21864d5
Connection string option is USE_MYCNF. OPTIONS bit 65536 may also be
used. The option enables reading of odbc section from default cnf file. Looking at the C/C code - other sections that documentation says are always read, are also read in this case.
The checkbox for the option has been added to Windows setup dialog.
UPDATE: the test failed for some reason in travis, so I had to change it and I have overwritten initial commit. The commit hash here has been update.

Comment by Lawrin Novitsky [ 2019-03-19 ]

It's not a problem at all to add options for file and section name, but I'd prefer to keep things simple in this case. Btw "default my.cnf" on Windows mean that that is either my.cnf or my.ini, which looked first in system dir, then in windows dir, then, iirc, in C:\, and then in the application directory

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