arrays returned in text format

From: Konstantin Izmailov <pgfizm(at)gmail(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: arrays returned in text format
Date: 2016-03-05 04:32:55
Message-ID: CAAw-MsdLP=pDNUdw_czz9Fzqv40jXjmm31KED5XTF5t-qOFdzQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm using libpq to read array values, and I noticed that sometimes the
values are returned in Binary and sometimes - in Text format.

1. Returned in Binary format:
int formats[1] = { 1 }; // request binary format
res = PQexec(conn, "SELECT rgField FROM aTable", 1, formats);
assert(PQfformat(res, 0) == 1); // this is OK

2. Returned in Text format:
res = PQexec(conn, "SELECT ARRAY[1,2,3]", 1, formats);
assert(PQfformat(res, 0) == 1); // this fails???

This is not a big issue, I can parse the text representation of the array.
But I wanted to understand why Postgres returns data in Text format when
Binary was requested. Am I missing something?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2016-03-05 05:03:27 Re: arrays returned in text format
Previous Message David G. Johnston 2016-03-05 00:03:57 Re: multiple UNIQUE indices for FK