From: | Alexander Klayman <aklayman(at)mindspring(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Row Locking |
Date: | 2002-05-20 03:53:23 |
Message-ID: | 200205192353.23312.aklayman@mindspring.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I have a few basic question and either need an affirmation or correction.
Thank you very much for help in advance.
When using Row locks, when does the lock start, which rows does it lock and
when does it end? I was unable to find this info in documentation (maybe
because it is supposed to be implicit). I have the following idea:
BEGIN;
LOCK TABLE A IN ROW EXCLUSIVE MODE;
SELECT c FROM A WHERE id=1; # The row with d=1 is locked
if c then
DELETE FROM A WHEE id=1;
COMMIT; # The row (if remaining) is unlocked
Also, could I do something like this:
BEGIN;
LOCK TABLE A IN ROW EXCLUSIVE MODE;
cursor = SELECT c, id FROM A WHERE d=1;
while cursor.fetchone() # Next row is locked, previous row
if c then # (if remaining) is unlocked
DELETE FROM A WHERE id=id;
COMMIT;
Thanks.
From | Date | Subject | |
---|---|---|---|
Next Message | Jean-Michel POURE | 2002-05-20 07:31:31 | Re: [HACKERS] UTF-8 safe ascii() function |
Previous Message | Tom Lane | 2002-05-20 03:24:44 | Re: DBD::Pg: Placeholders not working |