Re: Getting the SQLSTATE after a failed connection

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Getting the SQLSTATE after a failed connection
Date: 2025-10-17 17:28:21
Message-ID: CAEudQApFaFYoGqdOAHy+bQ5h29RPMCD6dptbH0OB16bLq02E-A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi.

Em sex., 17 de out. de 2025 às 11:27, Daniele Varrazzo <
daniele(dot)varrazzo(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

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