X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.225.181]) by svr1.postgresql.org (Postfix) with ESMTP id BB419CC3D9 for ; Tue, 15 Jul 2003 15:17:20 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr5.postgresql.org [64.117.225.181]) (amavisd-new, port 10024) with ESMTP id 31277-05 for ; Tue, 15 Jul 2003 15:17:39 +0000 (GMT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 4BCA5CB9AA for ; Tue, 15 Jul 2003 12:17:09 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h6FFHZQ3022696; Tue, 15 Jul 2003 11:17:35 -0400 (EDT) To: Jan Bernhardt Cc: pgsql-sql@postgresql.org Subject: Re: Non-Blocking Locks (i.e. Oracle NOWAIT) In-reply-to: <20030715144438.27550a7e.jb@baltic-online.de> References: <20030715144438.27550a7e.jb@baltic-online.de> Comments: In-reply-to Jan Bernhardt message dated "Tue, 15 Jul 2003 14:44:38 +0200" Date: Tue, 15 Jul 2003 11:17:35 -0400 Message-ID: <22695.1058282255@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/181 X-Sequence-Number: 14295 Jan Bernhardt writes: > I have a multi-user application which synchronizes access to certain datasets > via the database itself. If a user has a project in that application open no > other user should be able to work on it too. When developing the application I > considered the database to be a place to handle the synchronization since > transactions are (normally) an integral part of a database system. When a user > opens a project the application firstly locks a corresponding row. But since I > don't want the application to block if that row is already locked I use the > Oracle "NOWAIT" feature (SELECT ... FOR UPDATE NOWAIT) which tries to receive > the lock on the specified row and if that row is already locked it returns > with an error without blocking and I can tell the user that the project is > already in use. You might be able to use the contrib/userlock module for this. regards, tom lane