initial work on postgres support

needs a LOT of work since postgres has several peculiar behaviours