Fix PostgreSQL bindings and add support to build directly with PostgreSQL instead of MySQL.

I intentionally left out WIN32 because I have no way of testing it on the target platform.