pg.ddx.io pgsql-general@postgresql.org mailing list archivehelp / color / mirror / Atom feed
libpq: How to cancel a COPY ... TO statement? 2+ messages / 2 participants [nested] [flat]
* libpq: How to cancel a COPY ... TO statement? @ 2021-11-08 18:59 Daniel Frey <d.frey@gmx.de> 2021-11-08 19:05 ` Re: libpq: How to cancel a COPY ... TO statement? Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 1 reply; 2+ messages in thread From: Daniel Frey @ 2021-11-08 18:59 UTC (permalink / raw) To: pgsql-general@lists.postgresql.org Hi, after sending a COPY ... TO statement with PQsendQuery(), how can I cancel it properly? I tried using PQcancel(), but it seems to have no effect. Calling PQgetCopyData() or PQgetResult() afterwards does not go into a failure state. And I don't want to call PQgetCopyData() until it returns -1, as this might be a lot of data being read from the server that I don't need. BR, Daniel ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: libpq: How to cancel a COPY ... TO statement? 2021-11-08 18:59 libpq: How to cancel a COPY ... TO statement? Daniel Frey <d.frey@gmx.de> @ 2021-11-08 19:05 ` Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2021-11-08 19:05 UTC (permalink / raw) To: Daniel Frey <d.frey@gmx.de>; +Cc: pgsql-general@lists.postgresql.org Daniel Frey <d.frey@gmx.de> writes: > after sending a COPY ... TO statement with PQsendQuery(), how can I cancel it properly? > I tried using PQcancel(), That's the correct way. > but it seems to have no effect. Calling PQgetCopyData() or PQgetResult() afterwards does not go into a failure state. And I don't want to call PQgetCopyData() until it returns -1, as this might be a lot of data being read from the server that I don't need. You can't expect instantaneous response to a cancel. For one thing, the server might have already stuffed a good deal of data down the pipe. You should keep pulling (and discarding) data until you get the end or error response. regards, tom lane ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2021-11-08 19:05 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2021-11-08 18:59 libpq: How to cancel a COPY ... TO statement? Daniel Frey <d.frey@gmx.de> 2021-11-08 19:05 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox