Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> writes:
> I actually thought that he's complaining about the fact that it gives him
> the same id twice if he runs it in two transactions rather than the delay
> until the first commits.
As written, he gets a delay (because of the LOCK) *and* duplicate IDs
(because with the serializable isolation level, the second xact can't
see the row inserted by the first, even after waiting for it to commit).
Worst of both worlds.
There's a reason why we provide sequences as primitive objects: you
can't build an equivalent behavior very easily under MVCC rules.
regards, tom lane