Fixing pg build.

refs #2499
- Properly reference pg client
- Fix broken sql queries
Merge pull request #3478 from halfdan/fix-pgsql

Fixing pg build.