X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3DDA456539 for ; Wed, 16 Mar 2005 18:59:24 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 06883-09 for ; Wed, 16 Mar 2005 18:59:01 +0000 (GMT) Received: from mxfep01.bredband.com (mxfep01.bredband.com [195.54.107.70]) by svr1.postgresql.org (Postfix) with ESMTP id CD89D5665D for ; Wed, 16 Mar 2005 18:58:56 +0000 (GMT) Received: from junk.nocrew.org ([213.115.110.204] [213.115.110.204]) by mxfep01.bredband.com with ESMTP id <20050316185853.XMMI7011.mxfep01.bredband.com@junk.nocrew.org>; Wed, 16 Mar 2005 19:58:53 +0100 Received: from tomas by junk.nocrew.org with local (Exim 3.35 #1 (Debian)) id 1DBdjJ-0007l5-00; Wed, 16 Mar 2005 19:58:53 +0100 To: Kelly Burkhart Cc: pgsql-odbc@postgresql.org Subject: Re: 32-bit ints on 64-bit linux References: <4224F80D.2080103@kkcsm.net> <422727B1.9040104@kkcsm.net> From: tomas@nocrew.org (Tomas =?iso-8859-1?q?Sk=E4re?=) Date: 16 Mar 2005 19:58:53 +0100 In-Reply-To: <422727B1.9040104@kkcsm.net> Message-ID: <80ll8nifiq.fsf@junk.nocrew.org> Lines: 35 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200503/66 X-Sequence-Number: 5084 Kelly Burkhart writes: > Replying to my own message... > > Kelly Burkhart wrote: > > 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; > > It appears that SQL_C_LONG does correspond to a 32-bit integer and not > the native long. > > I'm attaching a patch which fixes this, and some other questionable > sprintf format strings in convert.c. Just a note on this. There are already standardized format string defines (when including inttypes.h) for different sizes: PRId8, PRId16, PRId32, PRId64, PRIu8, PRIu16, PRIu32, PRIu64, ... It may be better to use those. However, I don't know if they are available in Windows. Greetings, Tomas