On Wed, Dec 16, 2009 at 12:35 PM, Kevin Grittner
<Kevin.Grittner@wicourts.gov> wrote:
> "Chris Travers" <chris.travers@gmail.com> wrote:
>
>> I am noticing that that a failed database connection results in an
>> unusable SQLSTATE in libpq, and a very different SQLSTATE than the
>> backend registers.
>
> Well, if the client fails to connect to the server, I'm not sure how
> the server could communicate its SQLSTATE to the client, in order to
> force them to match.
It does send an error message. Currently I end up parsing that error
message and checking to see if a connection is active. Unfortunately
this becomes annoying where the locale of the PostgreSQL instance
could change the messages received.
It would be nice to have at least an option for software to pick up a
code as to why a connection request fails instead of having to try to
deal with feedback intended for a human, but I would settle for at
least a SQLSTATE that indicated a connection problem instead of a
transaction issue (08001 or 08004) since these would be a lot less
ambiguous on the program interface side.
Best Wishes,
Chris Travers