[freetds] odbc on 64 bit machines...

Christos Zoulas christos at zoulas.com
Thu Aug 24 10:59:38 EDT 2006


Produces the following warnings:

odbc.c: In function `SQLParamOptions':
odbc.c:714: warning: cast to pointer from integer of different size
odbc.c: In function `SQLSetEnvAttr':
odbc.c:857: warning: cast from pointer to integer of different size
odbc.c:865: warning: cast from pointer to integer of different size
odbc.c:869: warning: cast from pointer to integer of different size
odbc.c: In function `_SQLSetConnectAttr':
odbc.c:5208: warning: cast from pointer to integer of different size
odbc.c:5255: warning: cast to pointer from integer of different size
odbc.c: In function `SQLSetConnectOption':
odbc.c:5300: warning: cast to pointer from integer of different size
odbc.c: In function `SQLSetStmtOption':
odbc.c:5549: warning: cast to pointer from integer of different size

These are caused by the mess on /usr/include/sqltypes.h on my sle-9 box:
(and SQL{U,}INTEGER being an int instead of a long and used in the
 odbc code to cast from and to pointers!)

/*
 * can't use a long it fails on 64 platforms
 */

/*
 * I (Nick) have made these changes, to cope with the new 3.52 MS
 * changes for 64 bit ODBC, but looking at MS's spec they havn't
 * finished it themself. For example, SQLBindCol now expects the
 * indicator variable to be a SQLLEN which then is a pointer to
 * a 64 bit value. However the online book that comes with the
 * headers, then goes on to describe the indicator_ptr in the
 * descriptor record (which is set by SQLBindCol) as a pointer
 * to a SQLINTEGER (32 bit). So I don't think its ready for the
 * big time yet. Thats not to mention all the ODBC apps on 64 bit
 * platforms that this would break...
 *
 * I have just discovered that on win64 sizeof(long) == 4, so its
 * all smoke and mirrors...
 *
 */

#if (SIZEOF_LONG == 8)
#ifndef DO_YOU_KNOW_WHAT_YOUR_ARE_DOING
typedef int             SQLINTEGER;
typedef unsigned int    SQLUINTEGER;
#define SQLLEN          SQLINTEGER
#define SQLULEN         SQLUINTEGER
#define SQLSETPOSIROW   SQLUSMALLINT
typedef SQLULEN         SQLROWCOUNT;
typedef SQLULEN         SQLROWSETSIZE;
typedef SQLULEN         SQLTRANSID;
typedef SQLLEN          SQLROWOFFSET;
#else
typedef int             SQLINTEGER;
typedef unsigned int    SQLUINTEGER;
typedef long            SQLLEN;
typedef unsigned long   SQLULEN;
typedef unsigned long   SQLSETPOSIROW;
/*
 * These are not supprted on 64bit ODBC according to MS
 * typedef SQLULEN SQLTRANSID;
 */
typedef SQLULEN SQLROWCOUNT;
typedef SQLUINTEGER SQLROWSETSIZE;
typedef SQLLEN SQLROWOFFSET;
#endif
#else
typedef long            SQLINTEGER;
typedef unsigned long   SQLUINTEGER;
#define SQLLEN          SQLINTEGER
#define SQLULEN         SQLUINTEGER
#define SQLSETPOSIROW   SQLUSMALLINT
typedef SQLULEN         SQLROWCOUNT;
typedef SQLULEN         SQLROWSETSIZE;
typedef SQLULEN         SQLTRANSID;
typedef SQLLEN          SQLROWOFFSET;
#endif


So what to do here?

christos



More information about the FreeTDS mailing list