Re: Getting the SQLSTATE after a failed connection - Mailing list pgsql-hackers

From Ranier Vilela
Subject Re: Getting the SQLSTATE after a failed connection
Date
Msg-id CAEudQApFaFYoGqdOAHy+bQ5h29RPMCD6dptbH0OB16bLq02E-A@mail.gmail.com
Whole thread Raw
In response to Getting the SQLSTATE after a failed connection  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
Responses Re: Getting the SQLSTATE after a failed connection
List pgsql-hackers
Hi.

Em sex., 17 de out. de 2025 às 11:27, Daniele Varrazzo <daniele.varrazzo@gmail.com> escreveu:
Hello,

in ticket <https://github.com/psycopg/psycopg/issues/1188> an user
showed that, upon a failed connection attempt because of a bad
password, the server sends a SQLSTATE 28P01 message. However psycopg
cannot raise the expected `InvalidPassword` exception, because the
only way to get the SQLSTATE seems to be from a PGresult via
PQresultErrorField and I fail to see any API call to get the info from
a PGconn.
Have you seen the *pgpassfileWarning* function (src/interfaces/libpq/fe-connect.c)?
Does this sound like what you're looking for? 

best regards,
Ranier Vilela

pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: abi-compliance-check failure due to recent changes to pg_{clear,restore}_{attribute,relation}_stats()
Next
From: Jim Jones
Date:
Subject: Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement