libpq: How to cancel a COPY ... TO statement?

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

libpq: How to cancel a COPY ... TO statement?

От:
Daniel Frey <d.frey@gmx.de>
Дата:
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



Re: libpq: How to cancel a COPY ... TO statement?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Daniel Frey  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


FAQ