Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kAeE8-0001ro-2q for pgsql-docs@arkaria.postgresql.org; Tue, 25 Aug 2020 19:03:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kAeE6-0000wi-VW for pgsql-docs@arkaria.postgresql.org; Tue, 25 Aug 2020 19:03:22 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kAeE6-0000wb-PI for pgsql-docs@lists.postgresql.org; Tue, 25 Aug 2020 19:03:22 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kAeE0-0007iF-CE for pgsql-docs@lists.postgresql.org; Tue, 25 Aug 2020 19:03:21 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1kAeDx-0003FP-Sb; Tue, 25 Aug 2020 15:03:13 -0400 Date: Tue, 25 Aug 2020 15:03:13 -0400 From: Bruce Momjian To: Peter Eisentraut Cc: Pavel Stehule , "David G. Johnston" , Robin Abbi , Dave Cramer , Pg Docs Subject: Re: Procedures Message-ID: <20200825190313.GE26852@momjian.us> References: <20200822171447.GF26781@momjian.us> <20200824150056.GI26781@momjian.us> <20200824153557.GK26781@momjian.us> <20200824153847.GL26781@momjian.us> <20200824160023.GM26781@momjian.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="vGgW1X5XWziG23Ko" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --vGgW1X5XWziG23Ko Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Aug 25, 2020 at 08:38:11PM +0200, Peter Eisentraut wrote: > On 2020-08-24 18:00, Bruce Momjian wrote: > > - command, a procedure is called explicitly using > > - the statement. > > + command, a procedure is called in isolation using > > + the command. If the CALL command is not > > + part of an explicit transaction, a procedure can commit, rollback, > > + and begin new transactions during its execution, which is not possible > > + in functions. > > There are additional conditions for when a procedure can do transaction > control, and it also depends on the language. It's not clear how much > detail we should give in a general section like this. Often people read > this and then wonder why it doesn't work. I have updated the patch to mention it is dependend on the server-side language. -- Bruce Momjian https://momjian.us EnterpriseDB https://enterprisedb.com The usefulness of a cup is in its emptiness, Bruce Lee --vGgW1X5XWziG23Ko Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="proc.diff" diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml index 6de464c654..732d935521 100644 --- a/doc/src/sgml/xfunc.sgml +++ b/doc/src/sgml/xfunc.sgml @@ -84,8 +84,11 @@ A procedure is a database object similar to a function. The difference is that a procedure does not return a value, so there is no return type declaration. While a function is called as part of a query or DML - command, a procedure is called explicitly using - the statement. + command, a procedure is called in isolation using + the command. If the CALL command is not + part of an explicit transaction, a procedure in many server-side + languages can commit, rollback, and begin new transactions during + its execution, which is not possible in functions. --vGgW1X5XWziG23Ko--