Let's do it the SMF way

Re-implement the solution from 2b51fde0b667910aa280e9f8268f7ade00eab60f
so that it only affects PostgreSQL (and so that it won't break other
DBMSes should we ever want to switch).