Improve error message handling
Improve error message handling

It would be nice to get a PG_DIAG_SQLSTATE-style error code in the case when
the result pointer is null,  but how to accomplish this with libpq is not
obvious, if it's even possible at all.

cabrera/hdbc-postgresql,beni55/hdbc-postgresql,hdbc/hdbc-postgresql