libpq: do I need PQendcopy after PQgetCopyData? - Mailing list pgsql-general

From Nathaniel Trellice
Subject libpq: do I need PQendcopy after PQgetCopyData?
Date
Msg-id 773484.44742.qm@web25002.mail.ukl.yahoo.com
Whole thread Raw
Responses Re: libpq: do I need PQendcopy after PQgetCopyData?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
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






pgsql-general by date:

Previous
From: Raimon Fernandez
Date:
Subject: Extended Query vs Simple Query
Next
From: Tom Lane
Date:
Subject: Re: libpq: do I need PQendcopy after PQgetCopyData?