Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 6468B9FA639 for ; Fri, 24 Aug 2007 11:47:59 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 40010-09 for ; Fri, 24 Aug 2007 11:47:48 -0300 (ADT) X-Greylist: delayed 00:08:20.593167 by SQLgrey-1.7.5 Received: from nu.binary.net (nu.binary.net [216.229.0.6]) by postgresql.org (Postfix) with ESMTP id F01479FA612 for ; Fri, 24 Aug 2007 11:47:54 -0300 (ADT) Received: from tnt.microimages.com (unknown [216.229.5.227]) by nu.binary.net (Postfix) with ESMTP id BCDE78021 for ; Fri, 24 Aug 2007 09:39:31 -0500 (CDT) Received: by tnt.microimages.com (Postfix, from userid 65534) id 33719762D1; Fri, 24 Aug 2007 09:41:47 -0500 (CDT) Received: from [10.0.0.75] (unknown [10.0.0.75]) by tnt.microimages.com (Postfix) with ESMTP id DA90B762CE for ; Fri, 24 Aug 2007 09:41:46 -0500 (CDT) Message-ID: <46CEED0D.1040506@microimages.com> Date: Fri, 24 Aug 2007 09:37:01 -0500 From: Dave Williss User-Agent: Thunderbird 1.5.0.12 (Windows/20070509) MIME-Version: 1.0 To: pgsql-interfaces@postgresql.org Subject: libpq and error codes Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200708/11 X-Sequence-Number: 6605 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