From: Dave Williss <dwilliss@microimages.com>
To: pgsql-interfaces@postgresql.org
Subject: libpq and error codes
Date: Fri, 24 Aug 2007 09:37:01 -0500
Message-ID: <46CEED0D.1040506@microimages.com> (raw)
I can't seem to find a reliable way to determine if the error from a
call to PQconnectdb is due to an invalid username/password. I can call
PQstatus and it tells me CONNECTION_BAD, which I'd expect, and then
PQerrorMessage gives me a plain text message that explains the reason, but
error messages can be localized. A different version of PostgreSQL may
decide to change the wording, so just doing a string comparison on the
error message won't cut it.
What I need is a nice, numeric error code that I can compare to a known
value that means invalid password. But there doesn't seem to be any
function to do that. Am I just being blind?
The reason I need this is that in our software, if the user tries to
open a connection to a database and gets an authorization error of some
kind, we pop up a username/password dialog and let them try again. But
if it's due to any other kind of problem (server down, etc), we give
them the error message directly.
Dave Williss
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: dwilliss@microimages.com
Subject: Re: libpq and error codes
In-Reply-To: <46CEED0D.1040506@microimages.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox