Обсуждение: libpq: COPY FROM STDIN BINARY of arrays

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

libpq: COPY FROM STDIN BINARY of arrays

От
Dominique Devienne
Дата:
Hi,

I already use arrays fine (e.g. text[]) in BINARY mode binds (with prepared statement or not).
I already use COPY FROM STDIN BINARY fine, with scalar values.

But for the 1st time, I'm combining COPY with arrays,
and it is NOT fine yet :(

#08P01: ERROR:  insufficient data left in message
CONTEXT:  COPY UT_LibPQ_copy_arrays, line 1, column ptys

Does the wire-format of arrays differ between binary-binds and binary-copy?
Any pointers to what I could look at, to resolve this? doc? code? example?

Thanks, --DD

PS: If that helps, I'm willing to detail the break-down of all values / bytes I'm sending

Re: libpq: COPY FROM STDIN BINARY of arrays

От
Tom Lane
Дата:
Dominique Devienne <ddevienne@gmail.com> writes:
> Does the wire-format of arrays differ between binary-binds and binary-copy?

No.

> Any pointers to what I could look at, to resolve this? doc? code? example?

array_send and array_recv might help you.  Keep in mind that maybe the
problem is with array element(s) not the array structure proper.

            regards, tom lane



Re: libpq: COPY FROM STDIN BINARY of arrays

От
Dominique Devienne
Дата:
On Thu, Mar 30, 2023 at 6:00 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Dominique Devienne <ddevienne@gmail.com> writes:
> Does the wire-format of arrays differ between binary-binds and binary-copy?

No.

An update on this, I think I figure it out, by comparing with COPY TO STDOUT WITH (FORMAT BINARY).
I was missing the byte-count "header" for the array. Since I'm reusing my binary-bind code for COPY,
I'm missing the 4 bytes for the array's "total encoded byte length" before the array data proper.
Now that I understand the issue, should be a simple matter to fix. Thanks for chiming in Tom. --DD