32-bit ints on 64-bit linux - Mailing list pgsql-odbc

From Kelly Burkhart
Subject 32-bit ints on 64-bit linux
Date
Msg-id 4224F80D.2080103@kkcsm.net
Whole thread Raw
Responses Re: 32-bit ints on 64-bit linux
List pgsql-odbc
Greetings,

I am having a problem in running some code in 64 bit unix.  I'm running
unixODBC and psqlodbc-08.00.0005 on SuSE 9.1 x86-64.

If I bind a 32 bit integer using SQL_INTEGER/SQL_C_LONG and pass a value
of -1, the insert fails with an 'integer out of range' error.  The
reason this happens is the sprintf near line 2658 of convert.c.

    case SQL_C_SLONG:
    case SQL_C_LONG:
        sprintf(param_string, "%ld",
                *((SDWORD *) buffer));
        break;


How should this be fixed?  Should SQL_C_LONG/SQL_C_SLONG be identified
with the native C long of the compiler?  On Linux/GCC long is 64 bits.
On Windows 64, I believe a long will remain 32 bits.

It seems nicer to me to reserve SQL_C_LONG/SLONG for 32 bit ints and use
SQL_C_SBIGINT/SQL_C_UBIGINT for 64 bit ints.


An alternative approach would be to use:

ipdopts->parameters[param_number].column_size

to select an appropriate sprintf.

What do you ODBC experts consider an appropriate approach.

-K

pgsql-odbc by date:

Previous
From: anthony.caduto@micorp.com
Date:
Subject: Re: Using pg_dump through odbc
Next
From: Din Adrian
Date:
Subject: Re: Using pg_dump through odbc