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 AC3D052AA6 for ; Thu, 3 Mar 2005 15:05:26 +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 94874-04 for ; Thu, 3 Mar 2005 15:05:22 +0000 (GMT) Received: from tbserver.tradebot.com (mail.tradebotsystems.com [209.83.219.42]) by svr1.postgresql.org (Postfix) with ESMTP id 8644956385 for ; Thu, 3 Mar 2005 15:05:17 +0000 (GMT) Received: from [192.168.200.29] ([192.168.200.29]) by tbserver.tradebot.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 3 Mar 2005 09:05:21 -0600 Message-ID: <422727B1.9040104@kkcsm.net> Date: Thu, 03 Mar 2005 09:05:21 -0600 From: Kelly Burkhart User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-odbc@postgresql.org Subject: Re: 32-bit ints on 64-bit linux References: <4224F80D.2080103@kkcsm.net> In-Reply-To: <4224F80D.2080103@kkcsm.net> Content-Type: multipart/mixed; boundary="------------080701060402050702060300" X-OriginalArrivalTime: 03 Mar 2005 15:05:21.0792 (UTC) FILETIME=[6BA4E800:01C52002] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.257 tagged_above=0 required=5 tests=FORGED_RCVD_HELO, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200503/22 X-Sequence-Number: 5040 This is a multi-part message in MIME format. --------------080701060402050702060300 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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. -K --------------080701060402050702060300 Content-Type: text/x-patch; name="psqlodbc_convert.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="psqlodbc_convert.patch" --- psqlodbc-08.00.0005/convert.c 2005-01-17 04:12:52.000000000 -0600 +++ psqlodbc-08.00.0005.patch/convert.c 2005-03-03 08:26:38.443591978 -0600 @@ -180,18 +180,31 @@ #ifdef WIN32 #define ATOI64 _atoi64 #define ATOI64U _atoi64 -#define FORMATI64 "%I64d" -#define FORMATI64U "%I64u" #elif defined(HAVE_STRTOLL) #define ATOI64(val) strtoll(val, NULL, 10) #define ATOI64U(val) strtoull(val, NULL, 10) -#define FORMATI64 "%lld" -#define FORMATI64U "%llu" #else /* HAVE_STRTOLL */ #endif /* WIN32 */ #endif /* ODBCINT64 */ /* + * sprintf formats + */ +#define FORMATI8 "%hhd" +#define FORMATI8U "%hhu" +#define FORMATI16 "%hd" +#define FORMATI16U "%hu" +#define FORMATI32 "%d" +#define FORMATI32U "%u" +#ifdef WIN32 +# define FORMATI64 "%I64d" +# define FORMATI64U "%I64u" +#else +# define FORMATI64 "%lld" +# define FORMATI64U "%llu" +#endif + +/* * TIMESTAMP <-----> SIMPLE_TIME * precision support since 7.2. * time zone support is unavailable(the stuff is unreliable) @@ -2655,7 +2668,7 @@ case SQL_C_SLONG: case SQL_C_LONG: - sprintf(param_string, "%ld", + sprintf(param_string, FORMATI32, *((SDWORD *) buffer)); break; @@ -2673,28 +2686,28 @@ #endif /* ODBCINT64 */ case SQL_C_SSHORT: case SQL_C_SHORT: - sprintf(param_string, "%d", + sprintf(param_string, FORMATI16, *((SWORD *) buffer)); break; case SQL_C_STINYINT: case SQL_C_TINYINT: - sprintf(param_string, "%d", + sprintf(param_string, FORMATI8, *((SCHAR *) buffer)); break; case SQL_C_ULONG: - sprintf(param_string, "%lu", + sprintf(param_string, FORMATI32U, *((UDWORD *) buffer)); break; case SQL_C_USHORT: - sprintf(param_string, "%u", + sprintf(param_string, FORMATI16U, *((UWORD *) buffer)); break; case SQL_C_UTINYINT: - sprintf(param_string, "%u", + sprintf(param_string, FORMATI8U, *((UCHAR *) buffer)); break; --------------080701060402050702060300--