Skip site navigation (1) Skip section navigation (2)

Re: lock - feedback

From: Thomas Rokohl <rokohl(at)raygina(dot)de>
To: pgsql-odbc(at)postgresql(dot)org
Subject: Re: lock - feedback
Date: 2005-10-12 14:51:48
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-odbc
Merlin Moncure wrote:
> select user_write_lock(oid) from my_table where value = x;
> returns 1 on success, 0 on failure.
> just be careful...
> select user_write_lock(oid) from my_table where value = x order by y
> limit 1;
> can acquire more locks than you might think since the table has to be
> materialized to do the order.
> better to write:
> select user_write_lock(oid) from 
> (
>     select oid, *  from my_table where value = x order by y limit 1;
> )
> also, don't use oid :).  In my applications, I make a domain type called
> 'cuid' which pulls nextval() from a public sequence.  Put that into your
> tables and lock on it.  Just watch for dump/restore.
> Merlin

ok i understand, thanks. that work's.

but i'm a little bit confused. this problem is, from my point of view, a
highly frequently appearing problem.
on all places where it can be that two users edit the same record, the
"lost update" problem or the "waiting" problem ;-)  can be appeared.
and this is not rare i think.
your solution is good and works surely
<> fine( i will test
it ), but it is also unhandy.
my opinion is that this problem should be solved by the database and not
by the user, so i think it is a good point for a wish list ;-).

In response to

pgsql-odbc by date

Next:From: Merlin MoncureDate: 2005-10-12 15:04:24
Subject: Re: lock - feedback
Previous:From: Thomas RokohlDate: 2005-10-12 14:51:15
Subject: Re: lock - feedback

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group