Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id ADA069FBD66 for ; Wed, 23 May 2007 20:12:34 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 53503-08 for ; Wed, 23 May 2007 20:12:31 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from syd.object-craft.com.au (ppp167-236-184.static.internode.on.net [59.167.236.184]) by postgresql.org (Postfix) with ESMTP id 92B239FBD63 for ; Wed, 23 May 2007 20:12:30 -0300 (ADT) Received: by longblack.object-craft.com.au (Postfix, from userid 1000) id 9652A600895; Thu, 24 May 2007 09:12:28 +1000 (EST) Received: from longblack (localhost [127.0.0.1]) by longblack.object-craft.com.au (Postfix) with ESMTP id 7E80D600892; Thu, 24 May 2007 09:12:28 +1000 (EST) To: Jeff Lynn cc: pgsql-interfaces@postgresql.org Subject: Re: How do you convert PostgreSQL internal binary field to C datatypes In-reply-to: <46546220.4060209@rogers.com> References: <46546220.4060209@rogers.com> Comments: In-reply-to Jeff Lynn message dated "Wed, 23 May 2007 11:47:44 -0400." Date: Thu, 24 May 2007 09:12:28 +1000 From: Andrew McNamara Message-Id: <20070523231228.9652A600895@longblack.object-craft.com.au> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/50 X-Sequence-Number: 6557 >I give up! What ever data returned from the binary output of >PGgetvalue() is, I don't know how to convert it into StringInfo, which >is being used by a few routines that "seems" to convert internal binary >format into float8. By casting the returned data into StringInfo, >crashes the function. > >If PostgreSQL support only a half baked C API, may as well don't bother. > >So I gave up. I will not use PostgreSQL until there is a simple way to >extract data directly into C or C++ data type. Is one expect to fetch >data in text, then use text to int, text to double, text to date >function before you can make any business logic works? Even in a binary format, much processing is necessary - the format has to be architecture-independent. So, whether you choose text or binary format, you will have to "parse" the returns, and "format" the parameters. Please, just try the text format for parameters and result. I could measure no difference in performance (if anything, the text format was fractionally faster)! The text format is much easier to get working and more forgiving with respect to typing. Once your application is working, then evaluate whether the text conversion is a problem. -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/