libpq: binary data vs textual

Started by Вячеслав Блинниковabout 15 years ago4 messagesgeneral
Jump to latest

Database returns information from "integer" and "biging" fields as text
(values represented as string which must be read via atoi()/atol()) - is
there a way to retrieve such data as binary? Will not PostgreSQL suddenly
start return information in binary format (while I will continue read it as
text)?

#2Andy Colson
andy@squeakycode.net
In reply to: Вячеслав Блинников (#1)
Re: libpq: binary data vs textual

On 01/16/2011 08:13 AM, Вячеслав Блинников wrote:

Database returns information from "integer" and "biging" fields as
text (values represented as string which must be read via
atoi()/atol()) - is there a way to retrieve such data as binary? Will
not PostgreSQL suddenly start return information in binary format
(while I will continue read it as text)?

I assume you mean using libpq.

0) yes, you can get it as binary.
1) no, it wont switch.
2) you get to specify what format the server will return info, when you use PQexecParams().

See the paramFormats argument.

http://www.postgresql.org/docs/current/interactive/libpq-exec.html#LIBPQ-EXEC-MAIN

-Andy

#3Andy Colson
andy@squeakycode.net
In reply to: Andy Colson (#2)
Re: libpq: binary data vs textual

On 01/16/2011 09:07 AM, Andy Colson wrote:

On 01/16/2011 08:13 AM, Вячеслав Блинников wrote:

Database returns information from "integer" and "biging" fields as
text (values represented as string which must be read via
atoi()/atol()) - is there a way to retrieve such data as binary? Will
not PostgreSQL suddenly start return information in binary format
(while I will continue read it as text)?

I assume you mean using libpq.

0) yes, you can get it as binary.
1) no, it wont switch.
2) you get to specify what format the server will return info, when you use PQexecParams().

See the paramFormats argument.

http://www.postgresql.org/docs/current/interactive/libpq-exec.html#LIBPQ-EXEC-MAIN

-Andy

I assume you mean using libpq.

Oops. libpq, right in the subject... Jeez... sorry about that.

-Andy

In reply to: Andy Colson (#3)
Re: libpq: binary data vs textual

The claw "no, it wont switch." is enaugh. I think it's a good manner to use
some default settings - will read textual data.
Thanks!

16 января 2011 г. 18:11 пользователь Andy Colson <andy@squeakycode.net>написал:

Show quoted text

On 01/16/2011 09:07 AM, Andy Colson wrote:

On 01/16/2011 08:13 AM, Вячеслав Блинников wrote:

Database returns information from "integer" and "biging" fields as
text (values represented as string which must be read via
atoi()/atol()) - is there a way to retrieve such data as binary? Will
not PostgreSQL suddenly start return information in binary format
(while I will continue read it as text)?

I assume you mean using libpq.

0) yes, you can get it as binary.
1) no, it wont switch.
2) you get to specify what format the server will return info, when you
use PQexecParams().

See the paramFormats argument.

http://www.postgresql.org/docs/current/interactive/libpq-exec.html#LIBPQ-EXEC-MAIN

-Andy

I assume you mean using libpq.

Oops. libpq, right in the subject... Jeez... sorry about that.

-Andy