Streamline error handling in PostgreSQL backend with postgresql_result.

Make sure all PGresults are always correctly deallocated by wrapping them in
RAII postgresql_result class and simplify the error handling code by
integrating it into this class as well instead of copying the same code in
multiple places.

The only user-visible change is that postgresql_soci_error is now thrown even
if the connection to the server is completely lost, while a simple soci_error
was thrown before in this case.