Обсуждение: Protocol & Transmitted Field Data

Поиск
Список
Период
Сортировка

Protocol & Transmitted Field Data

От
Greg
Дата:
Hi everyone,

I have a question regarding field format used to transmit data (when data is transmitted over the protocol): Is there a way to change field format used by database to transmit data from text to binary?

Whats happening: I have 2 columns in a table, both integers, when they transmitted over to client, their values transmitted as a collection of characters e.g. number 1234567 represented as '1' '2' '3' '4' '5' '6' '7' instead of using 4 bytes for int4

Thanks!

Re: Protocol & Transmitted Field Data

От
Kenneth Marshall
Дата:
On Sun, Jul 04, 2010 at 04:00:25PM +0000, Greg wrote:
> Hi everyone,
>
> I have a question regarding field format used to transmit data (when data is transmitted over the protocol): Is there
away to change field format used by database to transmit data from text to binary? 
>
> Whats happening: I have 2 columns in a table, both integers, when they transmitted over to client, their values
transmittedas a collection of characters e.g. number 1234567 represented as '1' '2' '3' '4' '5' '6' '7' instead of
using4 bytes for int4 
>
> Thanks!
>

You need to use PQexecParams() with binary parameters. You can also request the results
in either binary or text:

http://www.postgresql.org/docs/9.0/static/libpq-exec.html

Cheers,
Ken

Re: Protocol & Transmitted Field Data

От
Greg
Дата:
Thanks!



--- On Sun, 4/7/10, Kenneth Marshall <ktm@rice.edu> wrote:

From: Kenneth Marshall <ktm@rice.edu>
Subject: Re: [NOVICE] Protocol & Transmitted Field Data
To: "Greg" <grigorey@yahoo.co.uk>
Cc: pgsql-novice@postgresql.org
Date: Sunday, 4 July, 2010, 17:07

On Sun, Jul 04, 2010 at 04:00:25PM +0000, Greg wrote:
> Hi everyone,
>
> I have a question regarding field format used to transmit data (when data is transmitted over the protocol): Is there a way to change field format used by database to transmit data from text to binary?
>
> Whats happening: I have 2 columns in a table, both integers, when they transmitted over to client, their values transmitted as a collection of characters e.g. number 1234567 represented as '1' '2' '3' '4' '5' '6' '7' instead of using 4 bytes for int4
>
> Thanks!
>

You need to use PQexecParams() with binary parameters. You can also request the results
in either binary or text:

http://www.postgresql.org/docs/9.0/static/libpq-exec.html

Cheers,
Ken