Bring postgres code into line with mysql