X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 4321F9DC811 for ; Thu, 26 Jan 2006 07:39:02 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72255-01 for ; Thu, 26 Jan 2006 07:39:04 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from r1.mycybernet.net (r1.mycybernet.net [209.5.206.8]) by postgresql.org (Postfix) with ESMTP id F10969DC801 for ; Thu, 26 Jan 2006 07:38:59 -0400 (AST) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227]:32789 helo=phlogiston.dydns.org) by r1.mycybernet.net with esmtp (Exim 4.50 (FreeBSD)) id 1F25Sw-000PlZ-Pz for pgsql-sql@postgresql.org; Thu, 26 Jan 2006 06:39:02 -0500 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 125FA4046; Thu, 26 Jan 2006 06:39:02 -0500 (EST) Date: Thu, 26 Jan 2006 06:39:02 -0500 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Changing the transaction isolation level within the stored Message-ID: <20060126113902.GB3995@phlogiston.dyndns.org> References: <1138198348.8828.32.camel@localhost.localdomain> <43D79132.9050900@logix-tt.com> <1138259463.16164.4.camel@localhost.localdomain> <43D8999E.9090907@logix-tt.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <43D8999E.9090907@logix-tt.com> User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.08 required=5 tests=[AWL=0.080] X-Spam-Score: 0.08 X-Spam-Level: X-Archive-Number: 200601/179 X-Sequence-Number: 23968 On Thu, Jan 26, 2006 at 10:42:54AM +0100, Markus Schaber wrote: > AFAIK, in PostgreSQL normal SQL commands cannot create deadlocks at all, > the only way to introduce deadlocks is to issue LOCK commands to take > locks manually. And for this rare case, PostgreSQL contains a deadlock > detection routine that will abort one of the insulting transactions, and > the others can proceed. You can too. Consider this: t1 t2 BEGIN; BEGIN; UPDATE table1 SET col1= UPDATE table2 SET col1= col1+5; (SELECT col3 FROM DELETE FROM table2 WHERE table3); col1 = col1+6; UPDATE table1 SET col1 = col1 +5; COMMIT; COMMIT; Suppose these are concurrent. The problem here is that each transaction need something in the other transaction either to complete or rollback before the work can proceed. So one of them has to lose. A -- Andrew Sullivan | ajs@crankycanuck.ca This work was visionary and imaginative, and goes to show that visionary and imaginative work need not end up well. --Dennis Ritchie