Uploaded image for project: 'MariaDB Connector/C'
  1. MariaDB Connector/C
  2. CONC-274

Alternative mysql_real_connect_dsn() working with "connection_string" argument (same as Dsn in ODBC).

Details

    • New Feature
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • None
    • 3.3.0
    • None
    • 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.

      Attachments

        Activity

          georg Georg Richter added a comment - - edited

          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).

          georg Georg Richter added a comment - - edited 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).
          andywolk Andrey Volk added a comment -

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

          andywolk Andrey Volk added a comment - @georg Please note `DNS` instead of `DSN` here CR_DNS_PARSE_ERROR and in a few other places.
          andywolk Andrey Volk added a comment -

          DNS instead of DSN?

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

          andywolk Andrey Volk added a comment - DNS instead of DSN? /* 5011 */ "DNS parse error (offset %d)",

          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
          serg Sergei Golubchik added a comment - 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

          questions:

          • separate function or mysql_real connect?
          • dsn or url?
          • if dsn, use the driver: prefix? what for?
          serg Sergei Golubchik added a comment - questions: separate function or mysql_real connect? dsn or url? if dsn, use the driver: prefix? what for?
          georg Georg Richter added a comment - Added new macro mariadb_connect(). See https://github.com/mariadb-corporation/mariadb-connector-c/wiki/mariadb_connect

          People

            georg Georg Richter
            andywolk Andrey Volk
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.