Обсуждение: Row Level Locking Problem

Поиск
Список
Период
Сортировка

Row Level Locking Problem

От
"Cray2"
Дата:
Hi
   I have a big problem, when I try to lock a row locked previouly, It wait
until commit / rollback operation.
       How could lock a row if It is not locked already?
       Could I now if a row is locked?
       Could I get some error message from postgres when I do 'select ....
for update' to a locked row instead of wait for commit / rollback?


cray2@mail.com






Re: Row Level Locking Problem

От
Don Baccus
Дата:
At 02:33 PM 8/20/00 +0200, Cray2 wrote:
>    I have a big problem, when I try to lock a row locked previouly, It wait
>until commit / rollback operation.
>
>        How could lock a row if It is not locked already?
>
>        Could I now if a row is locked?
>
>        Could I get some error message from postgres when I do 'select ....
>for update' to a locked row instead of wait for commit / rollback?

Well, this is how it is supposed to work.  "select for update" only
works within a transaction and holds the lock until the transaction
is complete.

What exactly is it that you're trying to do?



- Don Baccus, Portland OR <dhogaza@pacifier.com> Nature photos, on-line guides, Pacific Northwest Rare Bird Alert
Serviceand other goodies at http://donb.photo.net.
 


Re: Row Level Locking Problem

От
Hannu Krosing
Дата:
Cray2 wrote:
> 
> Hi
> 
>     I have a big problem, when I try to lock a row locked previouly, It wait
> until commit / rollback operation.
> 
>         How could lock a row if It is not locked already?
> 
>         Could I now if a row is locked?
> 
>         Could I get some error message from postgres when I do 'select ....
> for update' to a locked row instead of wait for commit / rollback?

It is theoretically possible to write a function is_locked and then do

select .... for update where not is_locked(); 

and thereby lock only not-yet-locked functions.

------------------
Hannu


RE: Row Level Locking Problem

От
Juan Carlos Perez Vazquez
Дата:
> Well, this is how it is supposed to work.  "select for update" only
> works within a transaction and holds the lock until the transaction
> is complete.
>
> What exactly is it that you're trying to do?

Let us suppose that we have 2 transactions, and attempt to block the
same row in the two transactions. One of them will wait until in the other
it is commited or rollbacked.

Oracle has "select for update nowait",  it does that instead of waiting
the conclusion of the other  transaction, gives back an error to us saying
that the row already has been blocked.

I am looking for something similar to this, or in its defect, knowledge
if a row has been blocked, to avoid this waits, or information to make the
parameter 'nowait' to realize this operation

Juan Carlos Perez Vazquez
Cray2@mail.com


______________________________________________
FREE Personalized Email at Mail.com
Sign up at http://www.mail.com/?sr=signup



RE: Row Level Locking Problem

От
Juan Carlos Pérez Vázquez
Дата:
> Well, this is how it is supposed to work.  "select for update" only
> works within a transaction and holds the lock until the transaction
> is complete.
>
> What exactly is it that you're trying to do?
       Let us suppose that we have 2 transactions, and attempt to block the
same row in the two transactions. One of them will wait until in the other
it is commited or rollbacked.
   Oracle has "select for update nowait",  it does that instead of waiting
the conclusion of the other  transaction, gives back an error to us saying
that the row already has been blocked.
   I am looking for something similar to this, or in its defect, knowledge
if a row has been blocked, to avoid this waits
   Juan Carlos Perez Vazquez   Cray2@mail.com