[CONC-274] Alternative mysql_real_connect_dsn() working with "connection_string" argument (same as Dsn in ODBC). Created: 2017-08-09  Updated: 2021-11-12  Resolved: 2021-11-12

Status: Closed
Project: MariaDB Connector/C
Component/s: None
Affects Version/s: None
Fix Version/s: 3.3.0

Type: New Feature Priority: Minor
Reporter: Andrey Volk Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: None


 Description   

MYSQL * mysql_real_connect_dsn(MYSQL * mysql, const char * connection_string)
Would be nice to have such an alternative way to connect to a database.
That code exists in the ODBC connector already.
So I guess it is not a hard task to port it into the C connector.



 Comments   
Comment by Georg Richter [ 2017-08-22 ]

We shouldn't add a new API function, since mysql_real_connect supports connection plugins.
With a new connection plugin "dsn", which parses dsn strings, the call would look like:

mysql_real_connect(mysql, "dsn://host=192.168.3.1;user=foo;password=bar;port=3307", NULL, NULL., NULL, 0, NULL, flags);

ODBC doesn't support several settings that needs to be set via mysql_options, so I would suggest to use the key-values from my.cnf (there can be additional aliases).

Comment by Andrey Volk [ 2021-09-15 ]

@georg Please note `DNS` instead of `DSN` here CR_DNS_PARSE_ERROR and in a few other places.

Comment by Andrey Volk [ 2021-09-15 ]

DNS instead of DSN?

/* 5011 */ "DNS parse error (offset %d)",

Comment by Sergei Golubchik [ 2021-09-20 ]

What was implemented:

  • mariadb_dsn_connect(MYSQL *mysql, const char *dsn, ssize_t len)
  • DSN syntax is host=127.0.0.1;user=foo;passwd=bar;port=3306 or, e.g. host=localhost;multi_statements;multi_results
Comment by Sergei Golubchik [ 2021-09-20 ]

questions:

  • separate function or mysql_real connect?
  • dsn or url?
  • if dsn, use the driver: prefix? what for?
Comment by Georg Richter [ 2021-11-12 ]

Added new macro mariadb_connect(). See
https://github.com/mariadb-corporation/mariadb-connector-c/wiki/mariadb_connect

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