Just out of curiosity is there a reason PGDATA is not listed with the other environment variables here?:
http://stream.boxwatch.ru/docs/9.3/interactive/libpq-envars.html
-- Adrian Klaveradrian(dot)klaver(at)aklaver(dot)com