Hey all, Accordingly to the documentation of libpq, SQLSTATE code field "is not localizable, and is always present.". But it seems, in some cases it isn't. E.g.
/* the main code */ PGresult* res = Pg::PQexec(conn, "select 1"); Oid id = PQparamtype(res, 1); /* the notice receiver */ void myNoticeReceiver(void *arg, const PGresult *res) { /* Presents - "NOTICE" */ const char* severity = Pg::PQresultErrorField(res, PG_DIAG_SEVERITY); /* NOT presents - NULL. Why not "00000" ? */ const char* sqlstate = Pg::PQresultErrorField(res, PG_DIAG_SQLSTATE); /* Presents - "parameter number 1 is out of range 0..-1" */ const char* primary = Pg::PQresultErrorField(res, PG_DIAG_MESSAGE_PRIMARY); } So, SQLSTATE field is not always presents. Regards, Dmitriy