Forward error code from PostgreSQL to clients as well as messages

This changes work with #1 to forward error code to clients as well as messages.
This pull-req also includes changes to pgsql functions that generate pretty messages.