Re: libpq - check PGconn* - is it valid

From: Terry Lee Tucker <terry(at)leetuckert(dot)net>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: libpq - check PGconn* - is it valid
Date: 2006-10-11 16:11:07
Message-ID: 200610111211.07614.terry@leetuckert.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

On Wednesday 11 October 2006 11:33 am, Dmitriy Chumack <saint(at)apriorit(dot)com>
thus communicated:
> Hi everyone.
>
> I have such a problem. My application, some server, use libpq librarry
> to interact with PostgreSQL-8.1.0 database. Postgresql server and my
> server work on different computers in the local network. When my server
> starts, it creates pool of 10 connections to database. My server use
> PQexec() to submit queries to db. But when there is no network
> connection to the database (I simply unplug the network cable from
> computer on which PG server is run) and my server calls PQexec() -
> than it hangs in PQexec() call. And it will hang there for a very
> long time (I wait about 30 minutes and there is no result). And
> when I plug in the network cable back, PQexec() remains hanging (I
> wait about 10 minutes and there is no result too).
>
> I use simply (not ssl) connection to db.
>
> So how can I check PGconn pointer if it represent a health connection
> to prevent my server to hang in PQexec() call?
>
> Thanks in advance.

Use: ConnStatusType PQstatus(const PGconn *conn);
See the docs for details.
--
Terry Lee Tucker
Turbo's IT Manager
Turbo, division of Ozburn-Hessey Logistics
2251 Jesse Jewell Pkwy NE
Gainesville, GA 30501
Tel: (336) 372-6812 Fax: (336) 372-6812 Cell: (336) 363-4719
terry(at)turbocorp(dot)com
www.turbocorp.com

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Jeroen T. Vermeulen 2006-10-12 05:19:16 Re: libpq - check PGconn* - is it valid
Previous Message Dmitriy Chumack 2006-10-11 15:33:13 libpq - check PGconn* - is it valid