Re: [GENERAL] Results interpretation
От | Igor Korot |
---|---|
Тема | Re: [GENERAL] Results interpretation |
Дата | |
Msg-id | CA+FnnTz5okBnsM6HxheGtnP6gSZBgm6LJNSas0RUG5cnr9P=Ug@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: [GENERAL] Results interpretation ("Daniel Verite" <daniel@manitou-mail.org>) |
Ответы |
Re: [GENERAL] Results interpretation
|
Список | pgsql-general |
Hi, Daniel, On Sat, Aug 19, 2017 at 12:51 PM, Daniel Verite <daniel@manitou-mail.org> wrote: > 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. Thank you for an explanation. It would be nice if the documentation will explicitly state: "The result set mode (text or binary) depends on the query being executed". In my case I simply executing: SELECT t.table_catalog AS catalog, t.table_schema AS schema, t.table_name AS table, u.usename AS owner, c.oid AS table_id FROM information_schema.tables t, pg_catalog.pg_class c, pg_catalog.pg_user u WHERE t.table_name = c.relname AND c.relowner = usesysid AND (t.table_type = 'BASE TABLE' OR t.table_type = 'VIEW' OR t.table_type = 'LOCAL TEMPORARY') ORDER BY table_name; So I presume the result set will be in a text format, right? For all columns? Thank you. > > > Best regards, > -- > Daniel Vérité > PostgreSQL-powered mailer: http://www.manitou-mail.org > Twitter: @DanielVerite
В списке pgsql-general по дате отправления: