Move PostgreSQL functions out into the normal function path

Include in each of them a check to detect if the PostgreSQL
environment is configured before they try to execute.