Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 58D0263342A for ; Fri, 24 Jul 2009 06:52:41 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 15232-05 for ; Fri, 24 Jul 2009 09:52:25 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by mail.postgresql.org (Postfix) with ESMTP id 81BE16323B6 for ; Fri, 24 Jul 2009 06:52:30 -0300 (ADT) Received: from [10.0.0.5] (tillium.localnet [10.0.0.5]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 13A161E0454; Fri, 24 Jul 2009 17:52:27 +0800 (WST) Subject: Re: Bit by "commands ignored until end of transaction block" again From: Craig Ringer To: Glenn Maynard Cc: pgsql-sql@postgresql.org In-Reply-To: References: <4A67F5B6.4080409@archonet.com> <4A680603.9010707@archonet.com> Content-Type: text/plain Date: Fri, 24 Jul 2009 17:52:26 +0800 Message-Id: <1248429146.1101.193.camel@tillium.localnet> Mime-Version: 1.0 X-Mailer: Evolution 2.26.1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.04 tagged_above=-10 required=5 tests=AWL=0.040 X-Spam-Level: X-Archive-Number: 200907/122 X-Sequence-Number: 32863 On Thu, 2009-07-23 at 03:39 -0400, Glenn Maynard wrote: > I'm writing a Python library call. It has no idea whether the caller > happens to be inside a transaction already, and I don't want to > specify something like "always run this inside a transaction". > (Callers are equally likely to want to do either, and it's bad API to > force them to start a transaction--the fact that I'm using the > database at al should be transparent.) Personally, I'd think about moving the function into the database, using PL/PgSQL or even PL/PythonU if you have to. Why should DB use be transparent when you're modifying the DB? In one case you immediately make a change. In another case, you schedule a change to be applied if/when the current transaction commits, so the change may or may not occur at some point in the future. That is, IMO, a big difference. Most applications with this sort of thing will have app-level transaction APIs that contain and manage the DB-level ones anyway. > RELEASE SAVEPOINT would only COMMIT the transaction *if* the savepoint > that it's releasing started it. So, what you're really asking for boils down to nestable transactions? -- Craig Ringer