On Sun, Oct 12, 2025 at 1:27 PM Tom Lane <[email protected]> wrote:
> Sergey Fukanchik <[email protected]> writes: > > Does libpq have an API to extract this code? > > PQresultErrorField(res, PG_DIAG_SQLSTATE) should do, no? > > I believe the call flow is the following - no "res"/result is ever constructed: PGconn *PQconnectdb(const char *conninfo); ConnStatusType PQstatus(const PGconn *conn); // Connection_Bad char *PQerrorMessage(const PGconn *conn); // Obtains the error message; but there seems to be no equivalent of PQresultErrorField (e.g. PQconnErrorField) to obtain the SQLState field component thereof David J.
