Fix for PostgreSQL error on Mac OS X

We now use pg_query() instead of pg_send_query() which could result in
"Cannot set connection to blocking mode" error on Mac OS X.