Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 17AFF633982 for ; Fri, 24 Jul 2009 13:56:41 -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 92818-01 for ; Fri, 24 Jul 2009 16:56:30 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lists.commandprompt.com (host-159.commandprompt.net [207.173.203.159]) by mail.postgresql.org (Postfix) with ESMTP id 36BDF634000 for ; Fri, 24 Jul 2009 13:54:40 -0300 (ADT) Received: from perhan.alvh.no-ip.org (201-220-118-158.bk10-dsl.surnet.cl [201.220.118.158]) (authenticated bits=0) by lists.commandprompt.com (8.13.8/8.13.8) with ESMTP id n6OH3KgS026815 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 24 Jul 2009 10:03:22 -0700 Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 1C64ED419B; Fri, 24 Jul 2009 12:54:31 -0400 (CLT) Date: Fri, 24 Jul 2009 12:54:31 -0400 From: Alvaro Herrera To: Joshua Tolley Cc: Glenn Maynard , Richard Huxton , pgsql-sql@postgresql.org Subject: Re: Bit by "commands ignored until end of transaction block" again Message-ID: <20090724165431.GB15591@alvh.no-ip.org> References: <4A67F5B6.4080409@archonet.com> <20090723064656.GO25450@eddie> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20090723064656.GO25450@eddie> User-Agent: Mutt/1.5.20 (2009-06-14) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (lists.commandprompt.com [207.173.203.159]); Fri, 24 Jul 2009 10:03:23 -0700 (PDT) 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/123 X-Sequence-Number: 32864 Joshua Tolley escribió: > 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. If > you haven't explicitly opened one, PostgreSQL opens one for you before each > statement, and issues a COMMIT afterwards (or a ROLLBACK, if your statement > ran into an error). Statements within functions are always executed within the > same transaction, so you can issue SAVEPOINT commands anywhere in PL/pgSQL > functions without problems, because you're always in a transaction. No, actually you can't call SAVEPOINT inside a PL/pgSQL function (or any SPI user for that matter -- have you tried savepoints in LOLCODE?) Inside PL/pgSQL the only way to use savepoints is with EXCEPTION blocks. You are correct that you're always in a transaction, but in this context not all transactions are equal :-( (The problem, as we found out, is that the function must always have control at the same level of transaction nestedness in SPI; you can't just let the user define and release savepoints arbitrarily.) -- Alvaro Herrera http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc.