pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kelly Burkhart <pgkrb@kkcsm.net>
To: pgsql-odbc@postgresql.org
Subject: 32-bit ints on 64-bit linux
Date: Tue, 01 Mar 2005 17:17:33 -0600
Message-ID: <4224F80D.2080103@kkcsm.net> (raw)

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



view thread (8+ messages)  latest in thread

Message-ID: <4224F80D.2080103@kkcsm.net>
Permalink:  ../4224F80D.2080103@kkcsm.net/
Also on:    postgresql.org/message-id/4224F80D.2080103@kkcsm.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: pgkrb@kkcsm.net
  Subject: Re: 32-bit ints on 64-bit linux
  In-Reply-To: <4224F80D.2080103@kkcsm.net>
  References: <4224F80D.2080103@kkcsm.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox