Skip site navigation (1) Skip section navigation (2)

Re: How do you convert PostgreSQL internal binary field to C datatypes

From: Andrew McNamara <andrewm(at)object-craft(dot)com(dot)au>
To: Jeff Lynn <jmlynn(at)rogers(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: How do you convert PostgreSQL internal binary field to C datatypes
Date: 2007-05-23 23:12:28
Message-ID: 20070523231228.9652A600895@longblack.object-craft.com.au (view raw or flat)
Thread:
Lists: pgsql-interfaces
>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/

In response to

pgsql-interfaces by date

Next:From: jing hanDate: 2007-05-24 12:46:58
Subject: unexpected EOF on client connection
Previous:From: Jeroen T. VermeulenDate: 2007-05-23 19:35:31
Subject: Re: How do you convert PostgreSQL internal binary field to C datatypes

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group