PQstatus() detect change in connection...
От | Matthew Hagerty |
---|---|
Тема | PQstatus() detect change in connection... |
Дата | |
Msg-id | 5.1.0.14.2.20011017203421.01daad60@pop.voyager.net обсуждение исходный текст |
Ответы |
Re: PQstatus() detect change in connection...
|
Список | pgsql-hackers |
Greetings, PostgreSQL 7.1.3, FreeBSD-4.3-RELEASE, gcc 2.95.3 I'm trying to attempt to detect a failed backend connection, but a call to PQstatus() always returns the state of the backend when the call was made. For example, take this test code: PGconn *pgConn;PGresult *pgRes;int fdPGconn; int i = 0;int iNewState = 0;int iOldState = 60; pgConn = PQconnectdb("dbname=pglogd user=postgres"); while ( i == 0 ){ iNewState = PQstatus(pgConn); if ( iNewState != iOldState ) { iOldState = iNewState; printf("Connection State [%d]\n", iNewState); fdPGconn = PQsocket(pgConn); printf("Connection Socket [%d]\n", fdPGconn); } sleep(1);} PQfinish(pgConn); If you start this with the backend running, the status is CONNECTION_OK, then pull the plug on the backend, the call to PQstatus() will still return CONNECTION_OK, even though the backend is not running. Start this program with the backend not running, then start the backend, PQstatus() never sees the backend come to life... Am I reading PQstatus() wrong? Is there any way to detect when the backend goes down or comes back up? Thanks, Matthew
В списке pgsql-hackers по дате отправления: