Thread: Get status of connection (C)

Get status of connection (C)

From
zilch@home.se
Date:
I'm writing a pool manager to manage x connections to a pgsql postmaster.

The getConnection method has to check if the connection is still valid,
and try to reconnect if it ain't.

Do you guys have a good way of doing this?

Can I use PQstatus?

Should I make a little runCommand on it to try it out? Then what command?

If it's bad, should I run a PQfinish on it before reconnecting or not?

Thank you plenty!

---
Daniel Akerud

Re: Get status of connection (C)

From
"Tim Barnard"
Date:
Page 4 of the programmers reference states:
"At any time during connection, the status of the
connection may be checked, by calling PQstatus."
I use it and so far its worked great, by which I mean
it has subsequently reported bad connections after
having reported CONNECTION_OK, which has
happened when the backend has died.

Tim

----- Original Message -----
From: <zilch@home.se>
To: <pgsql-general@postgresql.org>
Sent: Tuesday, May 29, 2001 2:46 AM
Subject: [GENERAL] Get status of connection (C)


>
> I'm writing a pool manager to manage x connections to a pgsql postmaster.
>
> The getConnection method has to check if the connection is still valid,
> and try to reconnect if it ain't.
>
> Do you guys have a good way of doing this?
>
> Can I use PQstatus?
>
> Should I make a little runCommand on it to try it out? Then what command?
>
> If it's bad, should I run a PQfinish on it before reconnecting or not?
>
> Thank you plenty!
>
> ---
> Daniel Akerud
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>