Обсуждение: libpq: do I need PQendcopy after PQgetCopyData?

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

libpq: do I need PQendcopy after PQgetCopyData?

От
Nathaniel Trellice
Дата:
I'm working on a client library, written in C, and am using:

  COPY sometable TO STDOUT WITH BINARY

followed by calls to 'PQgetCopyData' to retrieve data from the table as a postgres binary stream.

All my DB interaction is synchronous.

I've had things working for some time, but recent enhancements are getting caught-out by a strange thing: even though
mycalls to 'PQgetCopyData' exhaust the stream (i.e. 'PQgetCopyData' is being called until it returns '-1'), if I then
querythe transaction status of the same connection with a call to 'PQtransactionStatus', I get a status of
'PQTRANS_ACTIVE'--itseems the server hasn't realised that the copy is over and done with. I was expecting
'PQTRANS_IDLE'.

So, even though the manual states that it's obsolete, do I need to issue a call to 'PQendcopy' to tell the server that
thecopy is complete? 

Please note: my client application needs to work against postgres v7.4 onwards, so I'm currently developing against a
v7.4test database and haven't (yet) checked to see if the same issue arises under more recent versions (it's a pain to
do--itrequires a whole bunch of other infrastructure to be switched over to later versions too). 

Nathaniel






Re: libpq: do I need PQendcopy after PQgetCopyData?

От
Tom Lane
Дата:
Nathaniel Trellice <naptrel@yahoo.co.uk> writes:
> So, even though the manual states that it's obsolete, do I need to issue a call to 'PQendcopy' to tell the server
thatthe copy is complete? 

No, but did you do a PQgetResult?  See the description of PQgetCopyData.

            regards, tom lane

Re: libpq: do I need PQendcopy after PQgetCopyData?

От
Nathaniel Trellice
Дата:
Tom Lane wrote:
No, but did you do a PQgetResult?  See the description of PQgetCopyData.

Oops! Thanks Tom. Even after many re-reads, I missed that final paragraph in the manual, and have wasted ages on this.
Nathaniel