Streamline error handling in PostgreSQL backend with postgresql_result.

The existing code was _probably_ correct but it was far from obvious as it manually called `PQclear()` in many different places and, most confusingly, sometimes did it in the function itself and sometimes in the `throw_xxx()` called from it. This commit makes the code _obviously_ correct by wrapping the results in a class.

It also definitely makes the code shorter and easier to modify in the future.

Commit log:

-------

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.