So the difference between conn->errorMessage and conn->last_sqlstate is
that erorrMessage is appended and last_sqstate is overwritten.
And it seems that changing this is not easy.
As to why I want this - there are several reasons for connection to be
rejected, like ERRCODE_CANNOT_CONNECT_NOW, ERRCODE_TOO_MANY_CONNECTIONS,
ERRCODE_INSUFFICIENT_PRIVILEGE, ERRCODE_DATA_CORRUPTED etc
I would like my client to behave differently based on a particular
errcode - sometimes wait and retry, sometimes choose another server,
sometimes just fail.
It would be perfect if I could simply configure libpq to do such
reactions automatically for me, but designing this properly seems to be
even harder than exposing connection sqlstate.
SQLSTATE codes are locale independent and it would help a lot if I could
use them instead of relying on localized messages.
---
Sergey