Add PostgreSQL support (SMF integration)

This adds PostgreSQL support to the SMF branch.