From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dave Williss <dwilliss@microimages.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: libpq and error codes
Date: Fri, 24 Aug 2007 12:41:51 -0400
Message-ID: <2158.1187973711@sss.pgh.pa.us> (raw)
In-Reply-To: <46CEED0D.1040506@microimages.com>
References: <46CEED0D.1040506@microimages.com>
Dave Williss <dwilliss@microimages.com> writes:
> 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.
Actually, in current releases you can --- the bad-password message is
deliberately not localized so that this is possible. Compare to the
PQnoPasswordSupplied #define provided by libpq-fe.h. (You can find
examples of this if you look into the source code for, for example,
psql.)
Of course, that pretty much sucks. As of 8.3 there will be a status
function PQconnectionUsedPassword() to provide a cleaner API for
deciding whether you should issue a password prompt.
The more general idea that we should associate SQLStates with each
distinct error report inside libpq is still far off, I'm afraid.
It's a big job and no one has shown interest in tackling it.
regards, tom lane
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: tgl@sss.pgh.pa.us, dwilliss@microimages.com
Subject: Re: libpq and error codes
In-Reply-To: <2158.1187973711@sss.pgh.pa.us>
* 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