Bug #44808 OSX: Problem when libiodbc.a and libmysqlclient.a are linked together
Submitted: 11 May 2009 23:46 Modified: 30 Jun 2009 22:26
Reporter: David Booher Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / ODBC Severity:S4 (Feature request)
Version:5.1.34 OS:MacOS
Assigned to: Assigned Account CPU Architecture:Any

[11 May 2009 23:46] David Booher
Description:
I am writing a Cocoa app that can use either an ODBC connection OR a native mySQLclient connection.  The problem happens on the ODBC after both libiodbc.a and libmysqlclient.a are linked into the same program.  A "use mysql" followed by a "show tables"  which normally returns a result set with 1 column (Tables_in_mysql).  When libmysqlclient.a is included in the link step, SQLNumResultCols will return 5 incorrectly when an ODBC connection is used.  This eventually causes BAD ACCESS errors in subsequent SQLGetData statements as anything with column number > 1 is invalid. 

How to repeat:
1).  Create Cocoa app
2).  Create a class that uses ODBC (libiodbc.a) calls
3).  Crate another class that uses native (mysqlclient.a) calls
4).  Observe the behavior in the ODBC class when SQLNumResultCols after a "show tables" on the mysql database. 

Suggested fix:
I'm continuing to build the native driver class using mysqlclient to see if the same type of behavior occurs with that driver.  I would hope that these two drivers can co-exist because I'd really like to have the choice of using mysqlclient connect or ODBC connect in the same application at connection time.
[12 May 2009 6:46] Sveta Smirnova
Thank you for the report.

I can not repeat described behavior. Please provide repeatable test case: program and command you used to compile it.
[12 May 2009 14:37] David Booher
An XCODE project has been uploaded to pub/mysql/upload under the filename dbooher_testODBC.tar.gz
It demonstrates the error when libmysqlclient.a is linked with the project.  The connection string is hard-coded with DSN, USERID, and PASSWORD of my local server, so that will have to be changed to test. 

Here is the output log when libmysqlclient.a is  NOT linked:
 
[Session started at 2009-05-12 09:15:39 -0500.]
2009-05-12 09:15:43.238 testODBC[38506:10b] Connection established
2009-05-12 09:15:43.241 testODBC[38506:10b] ODBCDriver: entering processStatement
2009-05-12 09:15:43.249 testODBC[38506:10b] ODBCDriver: allocating handle
2009-05-12 09:15:43.251 testODBC[38506:10b] ODBCDriver: Prepare Statement
2009-05-12 09:15:43.252 testODBC[38506:10b] ODBCDriver: Execute Statement
2009-05-12 09:15:43.256 testODBC[38506:10b] ODBCDriver: SQLNumResultCols
2009-05-12 09:15:43.259 testODBC[38506:10b] No result set from SQLExecDirect, exiting mySQLDriver
2009-05-12 09:15:43.267 testODBC[38506:10b] ODBCDriver: entering processStatement
2009-05-12 09:15:43.269 testODBC[38506:10b] ODBCDriver: allocating handle
2009-05-12 09:15:43.272 testODBC[38506:10b] ODBCDriver: Prepare Statement
2009-05-12 09:15:43.276 testODBC[38506:10b] ODBCDriver: Execute Statement
2009-05-12 09:15:43.280 testODBC[38506:10b] ODBCDriver: SQLNumResultCols
2009-05-12 09:15:43.284 testODBC[38506:10b] The number of columns is 1
2009-05-12 09:15:43.288 testODBC[38506:10b] The desc label is Tables_in_mysql
2009-05-12 09:15:43.289 testODBC[38506:10b] The desc type is Tables_in_mysql
2009-05-12 09:15:43.290 testODBC[38506:10b] finished getting column values
2009-05-12 09:15:43.295 testODBC[38506:10b] Leaving processStatement...
2009-05-12 09:15:43.298 testODBC[38506:10b] Disconnected

Here's what happens when it is: 

[Session started at 2009-05-12 09:36:24 -0500.]
2009-05-12 09:36:28.726 testODBC[38768:10b] Connection established
2009-05-12 09:36:28.733 testODBC[38768:10b] ODBCDriver: entering processStatement
2009-05-12 09:36:28.734 testODBC[38768:10b] ODBCDriver: allocating handle
2009-05-12 09:36:28.735 testODBC[38768:10b] ODBCDriver: Prepare Statement
2009-05-12 09:36:28.737 testODBC[38768:10b] ODBCDriver: Execute Statement
2009-05-12 09:36:28.738 testODBC[38768:10b] ODBCDriver: SQLNumResultCols
2009-05-12 09:36:28.739 testODBC[38768:10b] No result set from SQLExecDirect, exiting mySQLDriver
2009-05-12 09:36:28.739 testODBC[38768:10b] ODBCDriver: entering processStatement
2009-05-12 09:36:28.740 testODBC[38768:10b] ODBCDriver: allocating handle
2009-05-12 09:36:28.741 testODBC[38768:10b] ODBCDriver: Prepare Statement
2009-05-12 09:36:28.741 testODBC[38768:10b] ODBCDriver: Execute Statement
2009-05-12 09:36:28.743 testODBC[38768:10b] ODBCDriver: SQLNumResultCols
2009-05-12 09:36:28.751 testODBC[38768:10b] The number of columns is 5
2009-05-12 09:36:28.752 testODBC[38768:10b] The desc label is Tables_in_mysql
2009-05-12 09:36:28.752 testODBC[38768:10b] The desc type is Tables_in_mysql
2009-05-12 09:36:28.752 testODBC[38768:10b] The desc label is Tables_in_mysql
2009-05-12 09:36:28.754 testODBC[38768:10b] The desc type is Tables_in_mysql
2009-05-12 09:36:28.756 testODBC[38768:10b] The desc label is Tables_in_mysql
2009-05-12 09:36:28.760 testODBC[38768:10b] The desc type is Tables_in_mysql
2009-05-12 09:36:28.761 testODBC[38768:10b] The desc label is Tables_in_mysql
2009-05-12 09:36:28.761 testODBC[38768:10b] The desc type is Tables_in_mysql
2009-05-12 09:36:28.762 testODBC[38768:10b] The desc label is Tables_in_mysql
2009-05-12 09:36:28.763 testODBC[38768:10b] The desc type is Tables_in_mysql
2009-05-12 09:36:28.764 testODBC[38768:10b] finished getting column values

[Session started at 2009-05-12 09:36:28 -0500.]
Loading program into debugger…
[18 May 2009 7:07] Sveta Smirnova
Thank you for the feedback.

I still can not repeat described behavior.

Please indicate which version of Connector/ODBC you use and if you use iODBC or UnixODBC.
[18 May 2009 13:49] David Booher
I am using mySQL Connector/ODBC version 5.1.5
[19 May 2009 4:25] David Booher
Trace showing 5 columns on a "show tables" command

Attachment: mysql.log (application/octet-stream, text), 11.64 KiB.

[19 May 2009 7:19] Sveta Smirnova
Thank you for the feedback.

I still can not repeat described behavior.

Please specify if you use iODBC or UnixODBC. (Default is iODBC on Mac, but I want to be sure.)
[19 May 2009 11:49] David Booher
Since I'm using the ODBC Administrator in Mac to setup the DSN and linking libiodbc.a into my program, I assume I"m using the Mac ODBC and the mySQL Connector/ODBC.   I have tried linking libiodb.a as a static and also using the dylib, but the result is the same.  I still se SQLNumResultCols returning 5 columns for a "show tables" command....very strange.
[19 May 2009 12:08] Sveta Smirnova
Thank you for the feedback.

This looks like there is a problem in your environment. Something like some ODBC settings. But I asked my colleague to test it another time to be sure before close bug report as "Can't repeat".
[19 May 2009 18:21] Valeriy Kravchuk
Verified just as described with 5.1.34 on Mac OS X 10.5.6. This is what I've got:

valeriy-kravchuks-macbook-pro:Debug openxs$ testODBC.app/Contents/MacOS/testODBC testODBC.app/
2009-05-19 21:14:35.628 testODBC[94597:10b] Connection established
2009-05-19 21:14:35.629 testODBC[94597:10b] ODBCDriver: entering processStatement
2009-05-19 21:14:35.630 testODBC[94597:10b] ODBCDriver: allocating handle
2009-05-19 21:14:35.630 testODBC[94597:10b] ODBCDriver: Prepare Statement
2009-05-19 21:14:35.630 testODBC[94597:10b] ODBCDriver: Execute Statement
2009-05-19 21:14:35.631 testODBC[94597:10b] ODBCDriver: SQLNumResultCols
2009-05-19 21:14:35.631 testODBC[94597:10b] No result set from SQLExecDirect, exiting mySQLDriver
2009-05-19 21:14:35.632 testODBC[94597:10b] ODBCDriver: entering processStatement
2009-05-19 21:14:35.632 testODBC[94597:10b] ODBCDriver: allocating handle
2009-05-19 21:14:35.632 testODBC[94597:10b] ODBCDriver: Prepare Statement
2009-05-19 21:14:35.633 testODBC[94597:10b] ODBCDriver: Execute Statement
2009-05-19 21:14:35.695 testODBC[94597:10b] ODBCDriver: SQLNumResultCols
2009-05-19 21:14:35.695 testODBC[94597:10b] The number of columns is 5
2009-05-19 21:14:35.696 testODBC[94597:10b] The desc label is Tables_in_mysql
2009-05-19 21:14:35.696 testODBC[94597:10b] The desc type is Tables_in_mysql
2009-05-19 21:14:35.697 testODBC[94597:10b] The desc label is Tables_in_mysql
2009-05-19 21:14:35.697 testODBC[94597:10b] The desc type is Tables_in_mysql
2009-05-19 21:14:35.697 testODBC[94597:10b] The desc label is Tables_in_mysql
2009-05-19 21:14:35.698 testODBC[94597:10b] The desc type is Tables_in_mysql
2009-05-19 21:14:35.698 testODBC[94597:10b] The desc label is Tables_in_mysql
2009-05-19 21:14:35.698 testODBC[94597:10b] The desc type is Tables_in_mysql
2009-05-19 21:14:35.699 testODBC[94597:10b] The desc label is Tables_in_mysql
2009-05-19 21:14:35.699 testODBC[94597:10b] The desc type is Tables_in_mysql
2009-05-19 21:14:35.699 testODBC[94597:10b] finished getting column values
[19 May 2009 19:22] David Booher
thank you thank you Valeriy!
[19 May 2009 19:51] Jim Winstead
I wonder if similar problems occur if a driver other than Connector/ODBC is used while linked to libmysqlclient. It seems likely that there is a conflict happening because of the presence of both the standalone libmysqlclient and the version of libmysqlclient linked into the Connector/ODBC driver.
[19 May 2009 21:03] David Booher
I also have Actual Technologies driver installed and it appears to co-exist with libmysqlclient.  The mySQL Connector/ODBC is the one that seems to not like it.
[30 Jun 2009 2:56] Jess Balint
Am I correct that there is no use of MYSQL* here?
[30 Jun 2009 22:26] David Booher
Yes, you are correct.  All examples of ODBC I've seen do not require a MYSQL *, just a connection, environment and statement handles.