libpq: do I need PQendcopy after PQgetCopyData?

From: Nathaniel Trellice <naptrel(at)yahoo(dot)co(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: libpq: do I need PQendcopy after PQgetCopyData?
Date: 2009-12-22 17:09:55
Message-ID: 773484.44742.qm@web25002.mail.ukl.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-12-22 17:15:55 Re: Extended Query, flush or sync ?
Previous Message Raimon Fernandez 2009-12-22 16:09:52 Re: Extended Query, flush or sync ?