Re: unixODBC, PostgreSQL 7.3 + ODBC V3 drivers? - Mailing list pgsql-odbc

From Alain Picard
Subject Re: unixODBC, PostgreSQL 7.3 + ODBC V3 drivers?
Date
Msg-id 15936.32945.34098.651127@outback.memetrics.local
Whole thread Raw
In response to Re: unixODBC, PostgreSQL 7.3 + ODBC V3 drivers?  (Hiroshi Inoue <Inoue@tpf.co.jp>)
List 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

pgsql-odbc by date:

Previous
From: Hiroshi Inoue
Date:
Subject: Re: unixODBC, PostgreSQL 7.3 + ODBC V3 drivers?
Next
From: Ocke Janssen
Date:
Subject: Re: OpenOffice and PostgreSQL: query with inner join