Postgres fixes

@sminnee @ajshort @simonwelsh  Its important to get this reviewed and merged quickly since it prevents module builds from effectively checking Postgres+3.1 compatibility, making it more likely that build breakages there will be ignored completely.