Re: unixODBC, PostgreSQL 7.3 + ODBC V3 drivers?

From: Alain Picard <Alain(dot)Picard(at)memetrics(dot)com>
To: Hiroshi Inoue <Inoue(at)tpf(dot)co(dot)jp>
Cc: Alain Picard <Alain(dot)Picard(at)memetrics(dot)com>, pgsql-odbc(at)postgresql(dot)org
Subject: Re: unixODBC, PostgreSQL 7.3 + ODBC V3 drivers?
Date: 2003-02-05 03:10:41
Message-ID: 15936.32945.34098.651127@outback.memetrics.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

>>>>> Hiroshi Inoue writes:

Hiroshi> I've just committed a change(odbcapi.c) to cvs.
Hiroshi> Please try.

Hiroshi, it works like a charm. There's still a bug remaining,
however, when connecting to a postgresql 7.3 back end; it's
not handling the BIGINTs properly. Here is a patch, for convert.c.

You need to remove the #ifdef WIN32 in the code below, because
we now want to execute this code on unix as well:

#if (ODBCVER >= 0x0300) && defined(ODBCINT64)
/* #ifdef WIN32 */
case SQL_C_SBIGINT:
len = 8;
if (bind_size > 0)
*(SQLBIGINT *) ((char *) rgbValue + (bind_row * bind_size)) = _atoi64(neut_str);
else
*((SQLBIGINT *) rgbValue + bind_row) = _atoi64(neut_str);
break;

case SQL_C_UBIGINT:
len = 8;
if (bind_size > 0)
*(SQLUBIGINT *) ((char *) rgbValue + (bind_row * bind_size)) = _atoi64(neut_str);
else
*((SQLUBIGINT *) rgbValue + bind_row) = _atoi64(neut_str);
break;

/* #endif */ /* WIN32 */
#endif /* ODBCINT64 */

And then you need to add

#ifndef WIN32
#define _atoi64 atoll
#endif

somewhere at the top of that file because _atoi64 doesn't exist under linux.
If you're not using GCC, or are on a system which doesn't support
`atoll', this will break; you can adjust the #define dance as you wish
to support other platforms, if you know how they behave. (I don't).

Also, the code above seems to be wrong for SQL_C_UBIGINT; I doubt that
_atoi64 (or atoll) will return an unsigned long long for a number
above 2^63.

Thank you so much for your _invaluable_ help.

--
Alain Picard
Memetrics

In response to

Browse pgsql-odbc by date

  From Date Subject
Next Message Nick Gorham 2003-02-05 09:49:14 Re: unixODBC, PostgreSQL 7.3 + ODBC V3 drivers?
Previous Message Hiroshi Inoue 2003-02-05 01:31:43 Re: unixODBC, PostgreSQL 7.3 + ODBC V3 drivers?