Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id B2B6563346D for ; Thu, 23 Jul 2009 04:07:01 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 40098-04 for ; Thu, 23 Jul 2009 04:06:51 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pz0-f195.google.com (mail-pz0-f195.google.com [209.85.222.195]) by mail.postgresql.org (Postfix) with ESMTP id 0D6236326C5 for ; Thu, 23 Jul 2009 04:06:50 -0300 (ADT) Received: by pzk33 with SMTP id 33so493034pzk.15 for ; Thu, 23 Jul 2009 00:06:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=LBY4CLpuHlHNW7stsr3X/ieb10kijbImUAKEv8zfu04=; b=XswG0/PAbXNk8dJvgT/eeWdXcGs4Jm3gcmcS0hu2fOsnFi+0B/byuaQeGqMBEe5R/D POz1okWxMxPOqqVOSKPOE4237A9PKBn6KmgF2CN7f3FWbxJfnI3zeQlFcYHddQVoEjpE Q7/vU9UO86jHGzQb6l/rnHWfS5Ix1V3DOH2vI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=ZSq9M5xgSnltHumRujsKhud3wM1JZhKwaJoo4qXaSdoAZumyX5WIqwmE90BVXKOk97 gzLJLWrY5k6DyrX6C/533d/HTss0MLJOGTWM8l/n41FZ80NI/5i+13hD7PQhS7tydl9z A0gQbPtEnEHzdv/hb3fM0fYYNFHdM4TDfMHgw= Received: by 10.114.103.15 with SMTP id a15mr2039726wac.184.1248332809854; Thu, 23 Jul 2009 00:06:49 -0700 (PDT) Received: from ?192.168.2.65? (office.squiz.net [203.206.128.174]) by mx.google.com with ESMTPS id l38sm2909190waf.26.2009.07.23.00.06.46 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 23 Jul 2009 00:06:48 -0700 (PDT) Message-ID: <4A680C03.6040701@gmail.com> Date: Thu, 23 Jul 2009 17:06:43 +1000 From: Chris User-Agent: Thunderbird 2.0.0.22 (X11/20090608) MIME-Version: 1.0 To: Joshua Tolley CC: Glenn Maynard , Richard Huxton , pgsql-sql@postgresql.org Subject: Re: Bit by "commands ignored until end of transaction block" again References: <4A67F5B6.4080409@archonet.com> <20090723064656.GO25450@eddie> In-Reply-To: <20090723064656.GO25450@eddie> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=-10 required=5 tests=none X-Spam-Level: X-Archive-Number: 200907/111 X-Sequence-Number: 32852 Joshua Tolley wrote: > On Thu, Jul 23, 2009 at 02:04:53AM -0400, Glenn Maynard wrote: >> On Thu, Jul 23, 2009 at 1:31 AM, Richard Huxton wrote: >>>> - Let me use SAVEPOINT outside of a transaction, >>> You are never outside a transaction. All queries are executed within a >>> transaction. >> "Transaction block", then, if you insist. >> >>> I think this is the root of your problem - all queries are within a >>> transaction so either: >>> 1. You have a transaction that wraps a single statement. If you get an error >>> then only that statement was affected. >>> 2. You have an explicit BEGIN...COMMIT transaction which could use a >>> savepoint. >> Savepoints can only be used inside transaction blocks. My function >> has no idea whether it's being called inside a transaction block. >> >> From inside a transaction block, my function would need to call >> SAVEPOINT/RELEASE SAVEPOINT. >> >> If it's not in a transaction block, it needs to call BEGIN/COMMIT >> instead. SAVEPOINT will fail with "SAVEPOINT can only be used in >> transaction blocks". > > Have you tried this? I expect if you give it a shot, you'll find you don't > actually have this problem. Really, everything is always in a transaction. Each statement is in it's own transaction, but the problem (as I understand it) is that you're in this sort of situation: psql -d dbname .. # select now(); now ------------------------------- 2009-07-23 17:04:21.406424+10 (1 row) Time: 2.434 ms (csmith@[local]:5432) 17:04:21 [test] # savepoint xyz; ERROR: SAVEPOINT can only be used in transaction blocks (csmith@[local]:5432) 17:04:25 [test] You haven't explicitly started a transaction, therefore savepoints won't work. Django (it seems) just issues queries with no knowledge of (and no way to support) them. -- Postgresql & php tutorials http://www.designmagick.com/