From: | Amir Zicherman <amir(dot)zicherman(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Locks in functions? |
Date: | 2004-08-10 22:58:03 |
Message-ID: | 27a5b7d104081015582e25f520@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
sorry, i wrote the funciton wrong. here is what i meant to write:
CREATE OR REPLACE FUNCTION public.sample(varchar)
RETURNS SETOF record AS
'
DECLARE
row RECORD;
BEGIN
LOCK TABLE table1 IN ROW SHARE MODE;
FOR urlrow in EXECUTE \'SELECT * FROM "table1"\'
LOOP
UPDATE "table1" SET col1=5 WHERE "col2"=6
RETURN NEXT row;
END LOOP;
RETURN;
END;
'
LANGUAGE 'plpgsql' VOLATILE;
thanx, amir
On Tue, 10 Aug 2004 15:53:33 -0700, Amir Zicherman
<amir(dot)zicherman(at)gmail(dot)com> wrote:
> will locks work inside functions or only in transactions?
>
> will this lock? ....
>
> CREATE OR REPLACE FUNCTION public.sample(varchar)
> RETURNS SETOF record AS
> '
> DECLARE
> row RECORD;
> BEGIN
> LOCK TABLE "URL" IN ROW SHARE MODE;
> FOR urlrow in EXECUTE \'SELECT * FROM "table1"\'
> LOOP
> UPDATE "table1" SET col1=5 WHERE "col2"=6
> RETURN NEXT row;
> END LOOP;
> RETURN;
> END;
> '
> LANGUAGE 'plpgsql' VOLATILE;
>
> thanx, amir
>
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2004-08-10 23:02:46 | Re: 7.4.3 server panic |
Previous Message | Scott Marlowe | 2004-08-10 22:57:49 | Re: Transaction blocks |