Compile-time bug in 3.51.12 (driver/results.c)

Compile-time bug in 3.51.12 (driver/results.c)

am 13.07.2006 22:10:11 von Tim Cartwright

OK, I gave up on using MySQL Connector/ODBC 3.51.12 with iODBC 3.52.3
and MySQL 4.1.19 (see previous post). Instead of iODBC, I switched to
unixODBC 2.2.11.

For me, building MyODBC 3.51.12 against unixODBC 2.2.11 flat out
fails. Here's the final compilation command and resulting error:

gcc -DHAVE_CONFIG_H -I. -I. -I. -L/home/cat/myodbc-manual-nmi-build/
globus/lib -L/home/cat/myodbc-manual-nmi-build/unixodbc/lib -I/home/
cat/myodbc-manual-nmi-build/unixodbc/include -O3 -DDBUG_OFF -L/home/
cat/myodbc-manual-nmi-build/globus/lib -L/home/cat/myodbc-manual-nmi-
build/unixodbc/lib -I/home/cat/myodbc-manual-nmi-build/mysql/include/
mysql -MT results.lo -MD -MP -MF .deps/results.Tpo -c results.c -
fPIC -DPIC -o .libs/results.o
results.c:563: conflicting types for `SQLColAttribute'
/home/cat/myodbc-manual-nmi-build/unixodbc/include/sql.h:603 :
previous declaration of `SQLColAttribute'

Here's the relevant unixODBC code in sql.h (formatted for email):

#if (ODBCVER >= 0x0300)
SQLRETURN SQL_API SQLCloseCursor(SQLHSTMT StatementHandle);

SQLRETURN SQL_API SQLColAttribute (
SQLHSTMT StatementHandle,
SQLUSMALLINT ColumnNumber,
SQLUSMALLINT FieldIdentifier,
SQLPOINTER CharacterAttribute,
SQLSMALLINT BufferLength,
SQLSMALLINT *StringLength,
SQLPOINTER NumericAttribute
/* spec says (SQLPOINTER) not (SQLEN*) - PAH */
);
#endif

And here's the code from driver/results.c:

//#if defined(__APPLE__)
SQLRETURN SQL_API SQLColAttribute(
SQLHSTMT StatementHandle,
SQLUSMALLINT ColumnNumber,
SQLUSMALLINT FieldIdentifier,
SQLPOINTER CharacterAttributePtr,
SQLSMALLINT BufferLength,
SQLSMALLINT *StringLengthPtr,
SQLLEN * NumericAttributePtr
)
/*#else
SQLRETURN SQL_API SQLColAttribute(
SQLHSTMT StatementHandle,
SQLUSMALLINT ColumnNumber,
SQLUSMALLINT FieldIdentifier,
SQLPOINTER CharacterAttributePtr,
SQLSMALLINT BufferLength,
SQLSMALLINT *StringLengthPtr,
SQLPOINTER NumericAttributePtr
)
#endif*/

Because the compiler directives are commented out, the compiler sees
the first version of SQLColAttribute in results.c and it does indeed
conflict with the unixODBC definition.

On a hunch, I removed the comment characters from this part of
results.c and tried again. With the compiler directives in place and
with compiling on Linux (not Mac OS X), the second, compatible
definition of SQLColAttribute should have been used. The compilation
succeeded through to the end. I don't have any runtime results yet,
but should soon.

Hope that helps.

--
Tim Cartwright, Condor Project & VDT
University of Wisconsin-Madison, Computer Science Dept.
1210 West Dayton Street, Room 4265; Madison, WI 53706; USA
Tel: +1 608 262 4002 / Email: cat@cs.wisc.edu

--
MySQL ODBC Mailing List
For list archives: http://lists.mysql.com/myodbc
To unsubscribe: http://lists.mysql.com/myodbc?unsub=gcdmo-myodbc@m.gmane.org