X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9D64AD1B19C for ; Thu, 10 Jun 2004 11:30:28 -0300 (ADT) 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 51107-06 for ; Thu, 10 Jun 2004 14:30:28 +0000 (GMT) Received: from hourri.hittite.isp.9tel.net (hourri.hittite.isp.9tel.net [62.62.156.10]) by svr1.postgresql.org (Postfix) with ESMTP id 1DB8DD1B16D for ; Thu, 10 Jun 2004 11:30:23 -0300 (ADT) Received: from [192.168.0.8] (45-105-118-80.kaptech.net [80.118.105.45]) by hourri.hittite.isp.9tel.net (Postfix) with ESMTP id 5CFAA1579ED for ; Thu, 10 Jun 2004 17:12:56 +0200 (CEST) Subject: libpq 7.4 and binary cursor From: Stephane Raimbault To: pgsql-interfaces@postgresql.org Content-Type: text/plain Message-Id: <1086877827.4646.22.camel@picasso.lan> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Thu, 10 Jun 2004 16:30:27 +0200 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/26 X-Sequence-Number: 4954 Hi, It seems some changes occured in network protocol between 7.3 and 7.4. In my simple libray above libpq, I used this call to extract float8 with a binary cursor (on x86) : ----------------------------------------------- memcpy(&float8, PQgetvalue(pg_res, tup_num, field_num), PQfsize(pg_res, field_num)); ----------------------------------------------- Now with PostgreSQL 7.4, I replaced this memcpy by theses lines : ----------------------------------------------- union { double d; int64_t i64; } swap; uint32_t tab_uint32[2]; /* Read two uint32 */ memcpy(tab_uint32, PQgetvalue(pg_res, tup_num, field_num), 8); /* Swap MSB -> LSB */ tab_uint32[0] = ntohl(tab_uint32[0]); tab_uint32[1] = ntohl(tab_uint32[1]); /* Fusion */ swap.i64 = tab_uint32[0]; swap.i64 <<= 32; swap.i64 |= tab_uint32[1]; /* Cast */ return swap.d; ------------------------------------------------ Is it the right method to extract binary data ? Don't exist a easiest method ? Thank you. Stephane