X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id BF72F9DC879 for ; Sat, 11 Feb 2006 19:45:47 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 98647-03 for ; Sat, 11 Feb 2006 19:45:49 -0400 (AST) X-Greylist: delayed 00:17:16.978013 by SQLgrey- Received: from adan.nsis.com.ar (unknown [200.61.186.68]) by postgresql.org (Postfix) with ESMTP id 568B89DC862 for ; Sat, 11 Feb 2006 19:45:45 -0400 (AST) Received: by adan.nsis.com.ar (Postfix, from userid 29) id AB57C2EC1F; Sat, 11 Feb 2006 20:31:44 -0300 (ART) Received: from PC1 (unknown [201.250.116.86]) by adan.nsis.com.ar (Postfix) with ESMTP id C19DB2E153 for ; Sat, 11 Feb 2006 20:31:43 -0300 (ART) Message-ID: <000301c62f62$dbd72b90$0300000a@PC1> From: "Mariano Reingart" To: Subject: LibPqEasy, binary cursor, x86-64, fetch(int4) problem? Date: Sat, 11 Feb 2006 20:28:25 -0300 X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2670 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 X-Sanitizer: Anomy (Adan NSIS Mail server) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200602/39 X-Sequence-Number: 6003 Hi, I recently moved a simple application from a 32bit Intel to a new AMD64 server (migrated from Postgres 7.2 to 8.1.2 and LibPqEasy 3.0.4), running Slamd64 (Slackware port to the AMD64). Everything compiled just fine but the applicattion didn't work as expected. When I look into the tables (with psql) I see strange values in int4 columns like ( 16777216, 402653184, 1124073472, ...) instead of normal ones (1, 24, 67) Looking at application logs I found that libpqeasy is returning bad values in fetch( &int4 ) functions. Thinking that my code is wrong, I run pginsert example from libpgeasy and it didn't work either. Using text cursors (not binary) and atoi() solved the problem. Here is a sample code to reproduce the bug, adapted from /libpgeasy-3.0.4/examples/pginsert.c: #include #include #include "libpq-fe.h" #include "libpgeasy.h" int main(void) { int aint; char astring[1024]; connectdb("dbname=fichadas"); on_error_stop(); doquery("BEGIN WORK"); doquery("CREATE TABLE testfetch(aint int4)"); doquery("INSERT INTO testfetch (aint) VALUES ( 1 )"); /* this will print a strange number like 16777216 instead of 1: */ doquery("DECLARE c_testfetch BINARY CURSOR FOR SELECT aint FROM testfetch WHERE aint=1"); doquery("FETCH ALL IN c_testfetch"); fetch(&aint); printf("aint=%d\n",aint); /* this will print a correct value: */ doquery("DECLARE c2_testfetch CURSOR FOR SELECT aint FROM testfetch WHERE aint=1"); doquery("FETCH ALL IN c2_testfetch"); fetch(astring); printf("atoi(astring)=%d\n",atoi(astring)); return 0; } /* ------------------------------- */ gcc -o test1 test1.c -lpgeasy Output: aint=16777216 atoi(astring)=1 Hope this helps, Regards, Mariano Reingart