Martijn van Oosterhout <kleptog@svana.org> writes:
> Why not just do it in a single transaction? I don't think you need to
> use SERIALIZABLE at all, I think normal read-committed mode will do
> what you want, no?
> BEGIN;
> INSERT INTO archive (...) SELECT ... FROM active WHERE user_id = ...;
> DELETE FROM active WHERE user_id = ...;
> COMMIT;
No, that's exactly wrong: in read-committed mode the DELETE could delete
rows that were not seen by the SELECT. It would work in serializable
mode though.
regards, tom lane