Re: Resetting libpq connections after an app error

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Resetting libpq connections after an app error
Дата
Msg-id 20202.1342888564@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Resetting libpq connections after an app error  (Martijn van Oosterhout <kleptog@svana.org>)
Ответы Re: Resetting libpq connections after an app error  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
Список pgsql-hackers
Martijn van Oosterhout <kleptog@svana.org> writes:
> On Sat, Jul 21, 2012 at 01:08:58AM +0100, Daniele Varrazzo wrote:
>> In a libpq application, if there is an application error between
>> PQsendQuery and PQgetResult, is there a way to revert a connection
>> back to an usable state (i.e. from transaction status ACTIVE to IDLE)
>> without using the network in a blocking way? We are currently doing

> There is PQreset(), which also exists in a non-blocking variant.

Note that PQreset essentially kills the connection and establishes a new
one, which might not be what Daniele is looking for.  The alternative
approach is to issue PQcancel and then just let the query flush out as
you normally would in an async application, ie PQisBusy/PQconsumeInput
until ready, then PQgetResult (which you throw away), repeat until you
get NULL.
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: Event Triggers reduced, v1
Следующее
От: Tom Lane
Дата:
Сообщение: Re: 9.2 release schedule