From: | "Colin Gillespie" <C(dot)Gillespie(at)newcastle(dot)ac(dot)uk> |
---|---|
To: | <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: triggers, transactions and locks |
Date: | 2004-12-07 10:11:36 |
Message-ID: | 20DA376D0C991745A4D5249F7BCD7A2521B4F3@largo.campus.ncl.ac.uk |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
>> Is there a way to use locks within a trigger? My example below gives
>> the error:
>> ERROR: unexpected error -8 in EXECUTE of query "BEGIN"
>> CONTEXT: PL/pgSQL function "insert_into_t1" line 6 at
>execute statement
>Can you tell us what you're trying to do? Why do you want to
>lock the table but not hold the lock until the outer transaction ends?
Hi Michael,
In my trigger after an update, the trigger scans the table and creates a
row new row with one the counters going from i=i+1. However, I've found
that if two updates occur together then two identical rows can be
created. Hence, I thought of locking the table within the trigger.
I presume from your email that the best way would be to lock the table
from the beginning of the transaction?
Thanks
Colin
>
>--
>Michael Fuhr
>http://www.fuhr.org/~mfuhr/
>
From | Date | Subject | |
---|---|---|---|
Next Message | Colin Gillespie | 2004-12-07 10:54:41 | Slow delete |
Previous Message | Tom Lane | 2004-12-07 06:01:09 | Re: message type 0x44 |