Skip to Content.
Sympa Menu

freetds - Re: [freetds] ODBC on 64 bit linux fix.

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Steve Langasek <vorlon AT dodds.net>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] ODBC on 64 bit linux fix.
  • Date: Thu, 17 Jan 2008 11:55:12 -0800

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.

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.

(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?)

> --- 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.

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.

--
Steve Langasek Give me a lever long enough and a Free OS
Debian Developer to set it on, and I can move the world.
Ubuntu Developer http://www.debian.org/
slangasek AT ubuntu.com vorlon AT debian.org




Archive powered by MHonArc 2.6.24.

Top of Page