X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AC8AAD7E95 for ; Wed, 12 Oct 2005 11:51:57 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35137-03 for ; Wed, 12 Oct 2005 14:51:51 +0000 (GMT) Received: from natnoddy.rzone.de (natnoddy.rzone.de [81.169.145.166]) by svr1.postgresql.org (Postfix) with ESMTP id 93CEFD7E53 for ; Wed, 12 Oct 2005 11:51:53 -0300 (ADT) Received: from [192.168.23.3] (F50a8.f.strato-dslnet.de [195.4.80.168]) (authenticated bits=0) by post.webmailer.de (8.13.1/8.13.1) with ESMTP id j9CEpvfU009259 for ; Wed, 12 Oct 2005 16:51:58 +0200 (MEST) Message-ID: <434D2304.3090501@raygina.de> Date: Wed, 12 Oct 2005 14:51:48 +0000 From: Thomas Rokohl User-Agent: Thunderbird 1.4.1 (Windows/20051006) MIME-Version: 1.0 To: pgsql-odbc@postgresql.org Subject: Re: lock - feedback References: <6EE64EF3AB31D5448D0007DD34EEB3417DD591@Herge.rcsinc.local> In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD591@Herge.rcsinc.local> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 required=5 tests=[AWL=0.007] X-Spam-Level: X-Archive-Number: 200510/64 X-Sequence-Number: 6166 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 ;-).