Resetting libpq connections after an app error

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Resetting libpq connections after an app error
Date: 2012-07-21 00:08:58
Message-ID: CA+mi_8Y6UZE9e__4BN0BoAODxE_-P_QHDZH7OLiyP0rQ415Mgg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

apologize for bumping the question to -hackers but I got no answer
from -general. If there is a better ML to post it let me know.

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

while (NULL != (res = PQgetResult(conn->pgconn))) {
PQclear(res);
}

but this is blocking, and if the error had been caused by the network
down, we'll just get stuck in a poll() waiting for a timeout.

Thank you very much.

-- Daniele

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chris Angelico 2012-07-21 01:57:43 Re: Pg_ctl promote -- wait for slave to be promoted fully ?
Previous Message Robert Haas 2012-07-20 20:28:11 Re: Restrict ALTER FUNCTION CALLED ON NULL INPUT (was Re: Not quite a security hole: CREATE LANGUAGE for non-superusers)