fix handling of optional hostname for PostgreSQL (closes #314)