libpq: do I need PQendcopy after PQgetCopyData?
libpq: do I need PQendcopy after PQgetCopyData?
От:
Nathaniel Trellice <naptrel@yahoo.co.uk>
Дата:
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 my calls to 'PQgetCopyData' exhaust the stream (i.e. 'PQgetCopyData' is being called until it returns '-1'), if I then query the transaction status of the same connection with a call to 'PQtransactionStatus', I get a status of 'PQTRANS_ACTIVE'--it seems 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 the copy is complete? Please note: my client application needs to work against postgres v7.4 onwards, so I'm currently developing against a v7.4 test database and haven't (yet) checked to see if the same issue arises under more recent versions (it's a pain to do--it requires 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 <tgl@sss.pgh.pa.us>
Дата:
Nathaniel Trellice writes: > So, even though the manual states that it's obsolete, do I need to issue a call to 'PQendcopy' to tell the server that the 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 <naptrel@yahoo.co.uk>
Дата:
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