From: | Maurizio Ortolan <crix98(at)tin(dot)it> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | php-psql lock problem |
Date: | 2001-10-14 19:24:12 |
Message-ID: | 5.1.0.14.2.20011014122242.00c91f48@mail.tin.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello to everybody!
I've a little problem with LOCK-ing a
certain row in a table using PHP and
PostgreSQL on LINUX.
>> In a few words, I'd like to undertand
>> how find out if a certain row is locked,
>> in order to prevent a kind of deadlock.
Which is the (system) table where all
locked row or tables are 'saved' ?
Is there any flag?
// ############################
Example 1:
User A:
BEGIN WORK;
select login from people where userid='1' for update;
[ ... ]
COMMIT WORK;
User B:
BEGIN WORK;
(***)
select login from people where userid='1' for update;
[ WAIT UNTIL 'COMMIT WORK' of user A ! :( ]
COMMIT WORK;
Solution:
I'd like to put in (***) a quick check in order to
know if the row with userid='1' is already locked or not.
In this way, if it's already locked, I'll use
select login from people where userid='1';
[ ONLY READ ]
instead of
select login from people where userid='1' for update;
[READ & WRITE]
// ############################
Example 2:
BEGIN WORK;
LOCK TABLE utenti IN SHARE ROW EXCLUSIVE MODE;
select login from people where userid='1';
COMMIT WORK;
// ############################
Many thanks to everybody!
Ciao!
MaURIZIO
crix98(at)____tin(dot)it
It's sure that
a small example in PHP will very very appreciated!! :))
PS: it's possible to setup a timeout for a locked table,
in order to exec an aoutomatic ROLLBACK ??
(for examples if the user goes away?
*******************************************
** Happy surfing on THE NET !! **
** Ciao by **
** C R I X 98 **
*******************************************
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2001-10-14 20:52:35 | Re: using a plan in a c function |
Previous Message | Emmanuel SARACCO | 2001-10-14 18:56:09 | using a plan in a c function |