From: Andrew McNamara <andrewm@object-craft.com.au>
To: Jeff Lynn <jmlynn@rogers.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: PQgetvalue failed to return column value for non-text data in binary format
Date: Mon, 21 May 2007 15:57:59 +1000
Message-ID: <20070521055759.848496006EA@longblack.object-craft.com.au> (raw)
In-Reply-To: <4651216B.2060707@rogers.com>
References: <4651216B.2060707@rogers.com>
>I am new to PostgreSQL and tried using the libpq C library. I can read
>a test table using PQgetvalue for text format, i.e. format = 0.
>However, when I experiment with using binary output format, I was unable
>to read anything else except result set fiend that is in char(x),
>varchar(x), i.e., character string data.
>
>What have I done wrong?
The data returned in binary mode is in a (largely undocumented)
PostgreSQL form. Types like int4, and float8 are returned in network
byte order [1], while other types such as timestamps are in more subtle
formats. The only canonical reference to these formats is the PostgreSQL
source.
In general, you should just use the text format, as it's more portable
and less likely to change over time, although the specifics of the text
format are also largely undocumented.
[1] http://en.wikipedia.org/wiki/Endianness
--
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: andrewm@object-craft.com.au, jmlynn@rogers.com
Subject: Re: PQgetvalue failed to return column value for non-text data in binary format
In-Reply-To: <20070521055759.848496006EA@longblack.object-craft.com.au>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox