Re: [GENERAL] Results interpretation - Mailing list pgsql-general

From Daniel Verite
Subject Re: [GENERAL] Results interpretation
Date
Msg-id 8db53839-aab7-40af-b866-41795760daac@manitou-mail.org
Whole thread Raw
In response to [GENERAL] Results interpretation  (Igor Korot <ikorot01@gmail.com>)
Responses Re: [GENERAL] Results interpretation  (Igor Korot <ikorot01@gmail.com>)
List pgsql-general
    Igor Korot wrote:

> If I do PQexec() call, the results will be interpreted as binary or text?
>
> I'm trying to get an int field from the query and wonder if I need to do
> hton() call or not?

In the most general case, you may call
PQfformat(const PGresult *res, int column_number)
to know if a column is in text (=0) or binary format (=1)

If you call PQexec("select 1") the result will be in text format.

But if you'd write for instance:
 PQexec("begin; declare c binary cursor for select 1; fetch all from c;
end;")
then the result would be in binary format.

The point is that using PQexec() does not strictly mean that the results
are in text, as it depends on the query itself. This might be
significant if there's a requirement that your code has to work
with any query.


Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite


pgsql-general by date:

Previous
From: Scott Mead
Date:
Subject: Re: [GENERAL] archive_command fails but works outside of Postgres
Next
From: Igor Korot
Date:
Subject: Re: [GENERAL] Results interpretation