Peter Eisentraut <peter_e@gmx.net> writes:
> AFAICT, error codes are only accessible through PGresult. But if the
> connection attempt fails, you have at best a PGconn. This is the same kind
> of issue we have with frontends parsing the "no password supplied" message,
> because PQconnect cannot supply an error code in this case.
Oh, right. Yes, we should do something about that. I think we could
invent PQerrorField which is to PQerrorMessage as PQresultErrorField
is to PQresultErrorMessage. The reason I didn't do so during the 7.4
cycle is that errors generated internally within libpq wouldn't have any
field information, at least not without significant hacking on the libpq
sources.
regards, tom lane