Is there public API to fetch errcode? - Mailing list pgsql-hackers

From Sergey Fukanchik
Subject Is there public API to fetch errcode?
Date
Msg-id 125437e5-25c8-49ad-99af-8de04b77daf6@postgrespro.ru
Whole thread Raw
Responses Re: Is there public API to fetch errcode?
List pgsql-hackers
Hi Postgres hackers,
ereport() can accept an error code. For example:
             ereport(FATAL,
                     (errcode(ERRCODE_TOO_MANY_CONNECTIONS),
                      errmsg("number of requested standby connections 
exceeds \"max_wal_senders\" (currently %d)",
                             max_wal_senders)));

In this case the error happens during connection initialization, outside 
of an SQL query. I.e. PGresult is not available.

I suspect that the error code is available on the client as 
PGconn->last_sqlstate however it is private and I can't find any public 
API to fetch it.

Does libpq have an API to extract this code?

---

Sergey




pgsql-hackers by date:

Previous
From: Arseniy Mukhin
Date:
Subject: Re: Finalizing read stream users' flag choices
Next
From: Tom Lane
Date:
Subject: Re: Add LZ4 compression in pg_dump