Uploaded image for project: 'CUBRID APIs'
  1. CUBRID APIs
  2. APIS-654

[ODBC] There is a problem when we use both DSN and Driver in an ODBC connection string

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Trivial
    • Resolution: Won't Fix
    • Affects Version/s: ODBC-9.2.0.0001, odbc 8.4.4.0002
    • Fix Version/s: None
    • Component/s: ODBC
    • Labels:
    • Environment:
      • OS: Win 32bit, Win 64 bit
      • CUBRID: 8.4.4.0227, 9.2.0.0139
      • Driver: odbc 8.4.4.0002, odbc 9.2.0.0001
      • Framework: .NET 4.0

      Description

      • Brief: If we add a valid DSN and an invalid Driver to an ODBC connection string, the connection gives different results when we change the DSN and Driver order
      • Case 1: {code}
        String strConn = @"Dsn=CUBRID_ODBC;Driver={Invalid CUBRID Driver};db_name=test_odbc;uid=dba;pwd=;server=xx.xx.xx.xx;port=xxxxx;fetch_size=100";
        OdbcConnection connCubrid = new OdbcConnection(strConn);
        connCubrid.Open();
        Assert.AreEqual(ConnectionState.Open, connCubrid.State);
        connCubrid.Close();{code}

      Result: Passed (The connection is opened)

      • Case 2 - change the Driver and the Dsn order in the connection string: {code}
        strConn = @"Driver={Invalid CUBRID Driver};Dsn=CUBRID_ODBC;db_name=test_odbc;uid=dba;pwd=;server=xx.xx.xx.xx;port=xxxxx;fetch_size=100";
        connCubrid = new OdbcConnection(strConn);
        connCubrid.Open();
        Assert.AreEqual(ConnectionState.Open, connCubrid.State);
        connCubrid.Close();{code}

      Result: Failed (The connection can not be opened)

        Activity

        Hide
        cn15800 谢韦华[Bert] added a comment - - edited

        When DSN is the first config item, odbc framework will not check Driver's name, and pass all parameters to driver. Driver will get config items from dsn, if there is repeated config item in connect string, driver will rewrite it, for example:

        {code}
        Dsn=CUBRID_ODBC;db_name=shard1; //CUBRID_ODBC.db_name=demodb Driver should not be config, because we have set Dsn.

        Driver will connect shard1.
        {code}

        When Driver is the first config item, odbc framework will check Driver name. If name is invalid,odbc framework will throw exception.

        Show
        cn15800 谢韦华[Bert] added a comment - - edited When DSN is the first config item, odbc framework will not check Driver's name, and pass all parameters to driver. Driver will get config items from dsn, if there is repeated config item in connect string, driver will rewrite it, for example: {code} Dsn=CUBRID_ODBC;db_name=shard1; //CUBRID_ODBC.db_name=demodb Driver should not be config, because we have set Dsn. Driver will connect shard1. {code} When Driver is the first config item, odbc framework will check Driver name. If name is invalid,odbc framework will throw exception.
        Hide
        cn15800 谢韦华[Bert] added a comment - - edited

        I have tested mysql odbc driver, there is the same problem.

        Odbc framework ues the config item(Driver) to find the corresponding driver. If user set a valid DSN,odbc framework have loaded driver successful, so odbc framework will not check the config item(Driver).

        Show
        cn15800 谢韦华[Bert] added a comment - - edited I have tested mysql odbc driver, there is the same problem. Odbc framework ues the config item(Driver) to find the corresponding driver. If user set a valid DSN,odbc framework have loaded driver successful, so odbc framework will not check the config item(Driver).
        Hide
        cn15800 谢韦华[Bert] added a comment -

        The exception is thrown by odbc framework,not driver. Driver doesn't need to use the config item,so we doesn't need to check it.

        Show
        cn15800 谢韦华[Bert] added a comment - The exception is thrown by odbc framework,not driver. Driver doesn't need to use the config item,so we doesn't need to check it.
        Hide
        ryin005 Ray Yin added a comment -

        The same result is returned by Mysql ODBC driver.

        It should be an ODBC framework issue but not caused by driver itself .

        Show
        ryin005 Ray Yin added a comment - The same result is returned by Mysql ODBC driver. It should be an ODBC framework issue but not caused by driver itself .

          People

          • Assignee:
            cn15800 谢韦华[Bert]
            Reporter:
            ryin005 Ray Yin
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: