X-Original-To: pgsql-sql@postgresql.org Received: from localhost (developer.postgresql.org [64.117.224.193]) by developer.postgresql.org (Postfix) with ESMTP id 5843E9235EE for ; Fri, 23 May 2003 11:42:13 -0400 (EDT) Received: from developer.postgresql.org ([64.117.224.193]) by localhost (developer.postgresql.org [64.117.224.193:10024]) (amavisd-new) with ESMTP id 66355-10 for ; Fri, 23 May 2003 11:41:54 -0400 (EDT) Received: from wolff.to (wolff.to [66.93.249.74]) by developer.postgresql.org (Postfix) with SMTP id 9B32892324A for ; Fri, 23 May 2003 11:06:17 -0400 (EDT) Received: (qmail 4495 invoked by uid 500); 23 May 2003 15:08:16 -0000 Date: Fri, 23 May 2003 10:08:16 -0500 From: Bruno Wolff III To: Jeffrey Pogodzinski Cc: pgsql-sql@postgresql.org Subject: Re: libpq program SELECT FOR UPDATE and TIMEOUT or CANCEL REQUEST Message-ID: <20030523150816.GA3935@wolff.to> Mail-Followup-To: Jeffrey Pogodzinski , pgsql-sql@postgresql.org References: <11c19c42.0305190955.967d34@posting.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <11c19c42.0305190955.967d34@posting.google.com> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new X-Archive-Number: 200305/472 X-Sequence-Number: 13637 On Mon, May 19, 2003 at 10:55:23 -0700, Jeffrey Pogodzinski wrote: > Hi, > > I am programming using libpq under Linux. > > When I do a "select ... for update" to lock a row, how > would I allow user to cancel or timeout when requesting the > the same row from another program/transaction. You can set statement_timeout. > I do not want the user to have to wait for the update on the > other end. I would rather send the user an error message > saying that the record is LOCKED -- try again later. It is generally bad design to hold database locks while waiting for user input. It is generally better to keep information about updates in a table and have the applications use this information to advise or prevent conncurrent updates to the same data by different people.