iODBC
iODBC copied to clipboard
iODBC doesn't map 3.x data types for 2.x applications
According to the docs at http://msdn.microsoft.com/en-us/library/ms714714(v=vs.85).aspx , ODBC driver managers should remap field type identifiers between ODBC 3.x (e.g., SQL_TYPE_TIMESTAMP=93) and 2.x (e.g., SQL_TIMESTAMP=11) when apps and drivers use different ODBC versions. iODBC does this in SQLDescribeCol, but not in SQLGetTypeInfo. As a result, apps that use ODBC version 2.x cannot successfully get field type information from drivers that use ODBC version 3.x. (Presumably the reverse is also true.)
This results in an error message ("Could not find SQL synonym for SQL_TIMESTAMP.") with the latest version of the AMPL ODBC handler (20131212, http://www.netlib.org/ampl/tables/amplodbc.c) when connecting to the latest version of the MySQL ODBC driver (5.3.2).
Recommended changes: update SQLGetTypeInfo code in iodbc/catalog.c to remap data types between ODBC 3.x and ODBC 2.x, depending on the ODBC version chosen by the app at runtime. This is similar to what is done in SQLDescribeCol in iodbc/result.c, but would require remapping the DataType argument of SQLGetTypeInfo and also the data_type specified in the result set returned by the driver (see http://msdn.microsoft.com/en-us/library/ms714632(v=vs.85).aspx ).