[freetds] ODBC on 64 bit linux fix.

Christos Zoulas christos at zoulas.com
Thu Jan 17 15:13:16 EST 2008


On Jan 17, 11:55am, vorlon at dodds.net (Steve Langasek) wrote:
-- Subject: Re: [freetds] ODBC on 64 bit linux fix.

| On Thu, Jan 17, 2008 at 02:25:24PM -0500, Christos Zoulas wrote:
| 
| > Here's a simple fix to make ODBC work on 64 bit machines. For those
| > unfamiliar with the problem, in 32 bit machines sizeof(pointer) ==
| > sizeof(int) and by definition some ODBC types are ints. At the same
| > time 2 ODBC routines assume that they can cast from pointer to int
| > and back. Linux provides the DO_YOU_KNOW_WHAT_YOUR_ARE_DOING macro
| > to fix the problem on 64 bit machines.  If you use this macro to
| > compile FreeTDS you'll need to compile the client code with that.
| > This patch enables the macro and also fixes an inconsistency in an
| > ODBC function declaration.
| 
| AFAIK, the 'DO_YOU_KNOW_WHAT_YOUR_ARE_DOING' define is obsoleted by
| 'BUILD_REAL_64_BIT_MODE' in recent versions of UnixODBC.

I am still running suse-9 at work, so I did not know that.

| This is also not the right place to make this change.  If UnixODBC is built
| in 64-bit mode, then everything that builds against it *also* needs to be
| built with the correct 64-bit API, which means that this switch should be
| hard-coded in the header files installed by UnixODBC.  So it's UnixODBC that
| should be patched, not FreeTDS.

I mentioned this (that other clients need to be built with that option). I
don't understand why this option is not the default on 64 bit systems.

| (For that matter, I'm staunchly of the opinion that UnixODBC should not
| offer a non-64bit-clean option.  What's the point of giving users the option
| of a broken ABI?)

I totally agree here. The code should not be compiled unless the user has
this option set.

| > --- freetds-0.83.dev.20080117/configure.ac	2008-01-11 07:43:39.000000000 -0500
| > +++ freetds-0.83.dev.20080117.new/configure.ac	2008-01-17 12:38:35.539382636 -0500
| > @@ -242,6 +242,7 @@
| >  #ifdef HAVE_WCHAR_H
| >  #include <wchar.h>
| >  #endif])
| > +AC_DEFINE(DO_YOU_KNOW_WHAT_YOUR_ARE_DOING, 1, [Hack for 64 bit ODBC])
| >  
| >  case 2 in
| >  $ac_cv_sizeof_short)   tds_sysdep_int16_type=short;;
| 
| So what's the point of making it a conditional define if it's not actually
| under the user's control?  This also further breaks things for users
| unfortunate enough to be on a platform where UnixODBC has been built without
| the 64-bit-clean API.

Which does not work anyway, so what's the point? At least building with
that option gives you a working 64-bit-ODBC.

| If you just need to build FreeTDS with the right interface and don't want
| to / aren't in a position to edit sqltypes.h, building with
| CFLAGS=-DBUILD_REAL_64_BIT_MODE should do the job.

I think that on 64 bit platforms, we should always ODBC build with that option
or not build it at all. The patch I sent always builds it with the option set,
since it is up to you if you want to use it or not. Building it without the
option produces a non-working library...

christos



More information about the FreeTDS mailing list