Обсуждение: promise postgres that I will only ROLLBACK

Поиск
Список
Период
Сортировка

promise postgres that I will only ROLLBACK

От
Gergely Riskó
Дата:
Hey,

I have a unit testing framework, where every test is ran in BEGIN..ROLLBACK, to ensure that data created during testing is never persisted.

Now, my question is: is there any way to tell postgres that

"Look, I will never ask you for a COMMIT, therefore you don't have to lock anything for me,
you just have to do a 'snapshot', fake my writes in my view of the world, then destroy all this on rollback".

This way, I would be able to run my many test cases in parallel, without worrying about locks/deadlocks between different testcases.

Something like BEGIN READ ONLY TRANSACTION WITH TEMPORARY WRITES...

I of course researched this a little bit, and I know that there are no out of the box syntax for this, but is there maybe some combinations of options which I can abuse to provide this?

(I can naturally do this on the filesystem with snapshots and LVM, but I would like something in postgres, so it doesn't become a sysadmin nightmare.)

Thank you for your ideas,
Gergely Risko