Re: BUG #13462: Impossible to use COPY FORMAT BINARY in chunks through libpq

From: Марк Коренберг <socketpair(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #13462: Impossible to use COPY FORMAT BINARY in chunks through libpq
Date: 2015-06-23 06:25:40
Message-ID: CAEmTpZHsf1iOm6eSoU1Jh5NZb5PgArgn4gn8EeoQX6HU3DqK8Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Where I can see example how to generate COPY FORMAT BINARY ? Seems,
I'm doing something wrong, but cannot figure out what exactly.
According to strace, library act as follow:

sendto ("COPY.....FROM STDIN (FORMAT binary)")
recv (...) => receive some response (that copy starts succesfully)
next, debugging and logging of PQputCopyData calls
logging of calling PQgetResult, that reports IMMEDIATELLY, that COPY failed.
and AFTER that, library sends "\d\0\0\0\27PGCOPY\n\377\r\n\0\0\....."

WTF?

If my example will work, I want to contribute that example to
documentation (as canonical example of that stuff), since I cannot
find working example of generating binary copy data.

2015-06-23 4:08 GMT+05:00 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> socketpair(at)gmail(dot)com writes:
>> If I use PQputCopyData() to pass parts of the binary protocol (as documented
>> in http://www.postgresql.org/docs/9.3/static/sql-copy.html ), postgres
>> binary socket data gets corrupted (i.e. protocol is broken).
>
> I think your test program is buggy; specifically, it doesn't appear to
> have any provision for dealing with data endianness, which means it
> will not work on a little-endian machine. Per the COPY binary format
> spec:
>
> Headers and data are in network byte order.
>
>
> regards, tom lane

--
Segmentation fault

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Hans Ginzel 2015-06-23 08:53:04 CREATE IF NOT EXISTS RLE/USER/INDEX
Previous Message Марк Коренберг 2015-06-23 06:13:04 Re: BUG #13462: Impossible to use COPY FORMAT BINARY in chunks through libpq