Re: triggers, transactions and locks

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: C G <csgcsg39(at)hotmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: triggers, transactions and locks
Date: 2004-12-06 15:59:04
Message-ID: 20041206075346.H37864@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Mon, 6 Dec 2004, C G wrote:

> Is there a way to use locks within a trigger? My example below gives the
> error:

It's not the lock that's the problem I think. The begin work is failing
because you can't start a transaction inside the function. Were you trying
to release the lock at the commit in the function?

> CREATE FUNCTION insert_into_t1() RETURNS trigger AS'
> DECLARE
> set_qry text;
> BEGIN
>
> set_qry:=''BEGIN WORK'';
> execute set_qry;
> LOCK t1;
> INSERT INTO t2 VALUES (11);
> COMMIT;
> RETURN NEW;
> END;
> ' LANGUAGE 'plpgsql' SECURITY DEFINER;

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message C G 2004-12-06 16:06:42 Re: triggers, transactions and locks
Previous Message Tom Lane 2004-12-06 15:53:18 Re: Performance tuning on RedHat Enterprise Linux 3