Skip site navigation (1) Skip section navigation (2)

32-bit ints on 64-bit linux

From: Kelly Burkhart <pgkrb(at)kkcsm(dot)net>
To: pgsql-odbc(at)postgresql(dot)org
Subject: 32-bit ints on 64-bit linux
Date: 2005-03-01 23:17:33
Message-ID: 4224F80D.2080103@kkcsm.net (view raw or flat)
Thread:
Lists: 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

Responses

pgsql-odbc by date

Next:From: Din AdrianDate: 2005-03-02 08:53:45
Subject: Re: Using pg_dump through odbc
Previous:From: anthony.cadutoDate: 2005-03-01 17:46:18
Subject: Re: Using pg_dump through odbc

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group