X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.192]) by svr1.postgresql.org (Postfix) with ESMTP id 5BF1CCC3D3 for ; Tue, 15 Jul 2003 14:54:24 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr4.postgresql.org [64.117.224.192]) (amavisd-new, port 10024) with ESMTP id 10212-02 for ; Tue, 15 Jul 2003 14:54:46 +0000 (GMT) Received: from fzkmail2.fzk.de (fzkmail2.fzk.de [141.52.27.52]) by svr1.postgresql.org (Postfix) with SMTP id 2F149CC3CF for ; Tue, 15 Jul 2003 11:54:21 -0300 (ADT) Received: FROM resy5.fzk.de BY fzkmail2.fzk.de ; Tue Jul 15 16:54:49 2003 +0200 Received: œby rodos.fzk.de with ESMTP (8.8.6 (PHNE_17135)/8.7.1) id QAA25897; Tue, 15 Jul 2003 16:54:48 +0200 (METDST) Message-ID: <3F1415B7.9001551F@rodos.fzk.de> Date: Tue, 15 Jul 2003 16:54:48 +0200 From: Christoph Haller X-Mailer: Mozilla 4.77 [en] (X11; U; HP-UX B.10.20 9000/780) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-sql@postgresql.org, jb@baltic-online.de Subject: Re: Non-Blocking Locks (i.e. Oracle NOWAIT) Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Amavis-Alert: BAD HEADER Non-encoded 8-bit data (char 9C hex) in message header 'Received' Received: \234by rodos.fzk.de... ^ X-Archive-Number: 200307/175 X-Sequence-Number: 14289 > > though this question has been asked several times before (but never really > answered), I have to give it another try. > > 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. > > Now that the application is to be ported to PG I need a similar functionality. > Is there that an animal? If not, what would you recommend? > PostgreSQL 7.3.2 T1: begin; select * from foo for update; T2: set STATEMENT_TIMEOUT = 1000; -- milliseconds T2: select * from foo for update; T2: ERROR: Query was cancelled. HTH, Christoph