X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4083ED70CD; Mon, 22 Aug 2005 15:20:21 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 77414-10; Mon, 22 Aug 2005 18:20:19 +0000 (GMT) Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) by svr1.postgresql.org (Postfix) with ESMTP id A6291D6D71; Mon, 22 Aug 2005 15:20:17 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1E7Gts-0007TK-00; Mon, 22 Aug 2005 14:20:00 -0400 To: "Marc G. Fournier" Cc: pgsql-sql@postgresql.org Subject: Re: PL/SQL Function: self-contained transaction? References: <20050822141357.B1002@ganymede.hub.org> In-Reply-To: <20050822141357.B1002@ganymede.hub.org> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 22 Aug 2005 14:20:00 -0400 Message-ID: <8764txj0kv.fsf@stark.xeocode.com> Lines: 25 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.003 required=5 tests=[AWL=0.003] X-Spam-Level: X-Archive-Number: 200508/188 X-Sequence-Number: 22416 "Marc G. Fournier" writes: > In PostgreSQL, as everyone knows, a QUERY == a transaction, unless wrap'd in a > BEGIN/END explicitly ... how does that work with a function? is there an > implicit BEGIN/END around the whole transaction, or each QUERY within the > function itself? The whole outer query issued from your frontend is in one transaction. > If the whole function (and all QUERYs inside of it) are considered one > transaction, can you do a begin/end within the function itself to 'force' > commit on a specific part of the function? Functions cannot issue start or end transactions. They're a creature of the transaction you're in when you call them. Otherwise it wouldn't make sense to be able to call them from within a query. There is some discussion of "stored procedures" which would live outside of transactions and be able to create transactions, commit, and roll them back. But I don't think any of that work is committed yet. I'm not even sure it's been written yet. -- greg