PostgreSQL pg_connection_status() bug?
| From: | Scott | Date: | Fri, 07 Dec 2007 23:05:30 +0000 |
| Subject: | PostgreSQL pg_connection_status() bug? | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-44396@lists.php.net to get a copy of this message | ||
I found some quite odd today and I am wondering if anyone else has encountered this (or can reproduce it) - or maybe I am just going crazy.
The function pg_connection_status() should return PGSQL_CONNECTION_BAD or null if the PostgreSQL service/database has stopped/restarted/ is not responding - after you have connected to it.
But what I encountered today suggests that is continues to return PGSQL_CONNECTION_OK after the stop / restart. It will only start returning PGSQL_CONNECTION_BAD if you try to run a query.
For example - this is what I am experiencing:
$link_id = pg_connect("dbname=test");
//do some queries ... etc ...
// pg_connection_status($link_id) equals PGSQL_CONNECTION_OK;
*** PostgreSQL database/service is stopped or restarted ***
// pg_connection_status($link_id) still equals PGSQL_CONNECTION_OK;
pg_query($link_id,$query); // this fails - outputs an error
// pg_connection_status($link_id) now equals PGSQL_CONNECTION_BAD or null;
Any comments or suggestions would be appreciated. Thanks.
Scott