On Fri, Feb 02, 2007 at 17:18:39 +0100,
Alban Hertroys <alban(at)magproductions(dot)nl> wrote:
>
> You can do this:
> INSERT INTO tbl_email (option_public, agency, id)
> SELECT $1, $2, MAX(id) + 1
> FROM xyz;
>
> I just realize you don't so much need a lock, you need a serialized
> transaction. I can't say I know a lot about locks, I usually prevent
> needing them.
No, a serialized transaction isn't good enough. You need predicate locking,
which postgres doesn't have. So you need to use lock table to do effectively
the same thing with a more blunt instrument.