lurcher / unixODBC

The unixODBC Project goals are to develop and promote unixODBC to be the definitive standard for ODBC on non MS Windows platforms.
GNU Lesser General Public License v2.1
100 stars 52 forks source link

iusql reports [ [ISQL]ERROR: Could not SQLDriverConnect error #102

Open vancaho opened 2 years ago

vancaho commented 2 years ago

Hi, I prepare two DSNs, one with the ANSI driver and the other with unicode driver in Macos 12.3.

➜  cat ~/.odbc.ini 
[ODBC Data Sources]
test  = MySQL ODBC 8.0 Unicode Driver
test2 = MySQL ODBC 8.0 ANSI Driver

[ODBC]
TraceLibrary = 

[test]
Driver   = /Library/ODBC/libmyodbc8w.so
SERVER   = localhost
PORT     = 3306
DATABASE = ftta-projects
USER     = root
PASSWORD = ******

[test2]
Driver   = /Library/ODBC/libmyodbc8a.so
SERVER   = localhost
PORT     = 3306
USER     = root
PASSWORD = ******

The isql command works fine with the test2 DSN of MySQL ODBC 8.0 ANSI Driver:

➜ isql -v test2
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> 

but iusql fails with test DSN of MySQL ODBC 8.0 Unicode Driver:

➜ iusql -v test
[
[ISQL]ERROR: Could not SQLDriverConnect

I opened the log file after running iusql, it reports that:

➜  ~ cat odbc.log 
[ODBC][94348][1648031781.405328][__handles.c][460]
        Exit:[SQL_SUCCESS]
            Environment = 0x7f854180a200
[ODBC][94348][1648031781.405454][SQLAllocHandle.c][377]
        Entry:
            Handle Type = 2
            Input Handle = 0x7f854180a200
        UNICODE Using encoding ASCII 'UTF-8' and UNICODE 'UCS-2-INTERNAL'

[ODBC][94348][1648031781.405753][SQLAllocHandle.c][513]
        Exit:[SQL_SUCCESS]
            Output Handle = 0x7f8542808200
[ODBC][94348][1648031781.405883][SQLDriverConnectW.c][290]
        Entry:
            Connection = 0x7f8542808200
            Window Hdl = 0x0
            Str In = [DSN=test][length = 8 (SQL_NTS)]
            Str Out = 0x0
            Str Out Max = 0
            Str Out Ptr = 0x0
            Completion = 0
[ODBC][94348][1648031781.420149][SQLDriverConnectW.c][699]
        Exit:[SQL_ERROR]
[ODBC][94348][1648031781.420238][SQLErrorW.c][375]
        Entry:
            Connection = 0x7f8542808200
            SQLState = 0x7ff7b1f7ddb0
            Native = 0x7ff7b1f7dda8
            Message Text = 0x7ff7b1f7ddd0
            Buffer Length = 500
            Text Len Ptr = 0x7ff7b1f7ddae
[ODBC][94348][1648031781.420407][SQLErrorW.c][430]
        Exit:[SQL_SUCCESS]
            SQLState = [H]
            Native = 0x7ff7b1f7dda8 -> 0 (32 bits)
            Message Text = [[]
[ODBC][94348][1648031781.420476][SQLErrorW.c][375]
        Entry:
            Connection = 0x7f8542808200
            SQLState = 0x7ff7b1f7ddb0
            Native = 0x7ff7b1f7dda8
            Message Text = 0x7ff7b1f7ddd0
            Buffer Length = 500
            Text Len Ptr = 0x7ff7b1f7ddae
[ODBC][94348][1648031781.420567][SQLErrorW.c][430]
        Exit:[SQL_NO_DATA]
[ODBC][94348][1648031781.420708][SQLErrorW.c][375]
        Entry:
            Environment = 0x7f854180a200
            SQLState = 0x7ff7b1f7ddb0
            Native = 0x7ff7b1f7dda8
            Message Text = 0x7ff7b1f7ddd0
            Buffer Length = 500
            Text Len Ptr = 0x7ff7b1f7ddae
[ODBC][94348][1648031781.420774][SQLErrorW.c][430]
        Exit:[SQL_NO_DATA]
[ODBC][94348][1648031781.420829][SQLFreeHandle.c][290]
        Entry:
            Handle Type = 2
            Input Handle = 0x7f8542808200
[ODBC][94348][1648031781.420888][SQLFreeHandle.c][339]
        Exit:[SQL_SUCCESS]
[ODBC][94348][1648031781.420942][SQLFreeHandle.c][220]
        Entry:
            Handle Type = 1
            Input Handle = 0x7f854180a200

What is the problem with iusql?

lurcher commented 2 years ago

On 23/03/2022 10:47, vancaho wrote:

Hi, I prepare two DSNs, one with the ANSI driver and the other with unicode driver in Macos 12.3.

|➜ cat ~/.odbc.ini [ODBC Data Sources] test = MySQL ODBC 8.0 Unicode Driver test2 = MySQL ODBC 8.0 ANSI Driver|

|My guess would be something going wrong between what the driver and the driver manager is expecting as unicode. unixODBC uses UTC-2 or UTF16 as its unicode, maybe the driver expects a 4 byte representation. I would look at driver debugging.|

TallTed commented 2 years ago

It's a strange error, for sure. I notice that the [test2] DSN which succeeds lacks the DATABASE = ftta-projects connection attribute. Perhaps removing that line from [test] and/or adding it to [test2] will change your results in a helpful way.

I don't expect the above to bring a better error message when testing the Unicode driver, because I think the line Message Text = [[] in that test log suggests @lurcher may be on the right track, thinking about conflicting Unicode representations/expectations.