Re: Is there public API to fetch errcode?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Is there public API to fetch errcode?
Дата
Msg-id 30345.1760292202@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Is there public API to fetch errcode?  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Re: Is there public API to fetch errcode?
Список pgsql-hackers
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Sun, Oct 12, 2025 at 1:27 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> PQresultErrorField(res, PG_DIAG_SQLSTATE) should do, no?

> I believe the call flow is the following - no "res"/result is ever
> constructed:

Hmm ... no, we do construct a PGresult containing the error (including
SQLSTATE), because pqGetErrorNotice3 is what's used to read the
server's error response.  But it looks like for a connection-time
failure, PQconnectPoll clears it before returning.

In principle maybe we could keep that around, allowing the application
to do PQgetResult from the failed connection object.  Seems like it'd
be a bit of a mess though.  Also, given all the logic that's there
to retry different server addresses etc, it's not clear which failure
result to preserve.  We sidestep that question so far as the textual
PQerrorMessage output is concerned by concatenating all the failures,
but that's not workable for PGresults.

            regards, tom lane



В списке pgsql-hackers по дате отправления: