Re: Defining and Using variables in a postgres function

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Alban Hertroys <alban(at)magproductions(dot)nl>
Cc: Harpreet Dhaliwal <harpreet(dot)dhaliwal01(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Defining and Using variables in a postgres function
Date: 2007-02-02 18:20:54
Message-ID: 20070202182054.GA6468@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2007-02-02 18:27:02 Re: Problem with Online-Backup
Previous Message Richard Huxton 2007-02-02 18:16:18 Re: Predicted lifespan of different PostgreSQL branches