Re: PQgetvalue failed to return column value for non-text data in binary format

Поиск
Список
Период
Сортировка
От Andrew McNamara
Тема Re: PQgetvalue failed to return column value for non-text data in binary format
Дата
Msg-id 20070521055759.848496006EA@longblack.object-craft.com.au
обсуждение исходный текст
Ответ на PQgetvalue failed to return column value for non-text data in binary format  (Jeff Lynn <jmlynn@rogers.com>)
Ответы Re: PQgetvalue failed to return column value for non-text data in binary format  (Jeff Lynn <jmlynn@rogers.com>)
Список pgsql-interfaces
>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/


В списке pgsql-interfaces по дате отправления:

Предыдущее
От: Jeff Lynn
Дата:
Сообщение: PQgetvalue failed to return column value for non-text data in binary format
Следующее
От: Jeff Lynn
Дата:
Сообщение: Re: PQgetvalue failed to return column value for non-text data in binary format