Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sSGXg-005lR0-MO for pgsql-docs@arkaria.postgresql.org; Fri, 12 Jul 2024 13:42:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sSGXf-008daz-Bw for pgsql-docs@arkaria.postgresql.org; Fri, 12 Jul 2024 13:42:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sSGXf-008dar-4H for pgsql-docs@lists.postgresql.org; Fri, 12 Jul 2024 13:42:31 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sSGXc-001mU4-6s for pgsql-docs@lists.postgresql.org; Fri, 12 Jul 2024 13:42:30 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 46CDgOQA2320321; Fri, 12 Jul 2024 09:42:24 -0400 From: Tom Lane To: "David G. Johnston" cc: "splarv@ya.ru" , "pgsql-docs@lists.postgresql.org" Subject: Re: Savepoints in plpgsql In-reply-to: References: <172076354433.736586.14347210271966220018@wrigleys.postgresql.org> Comments: In-reply-to "David G. Johnston" message dated "Fri, 12 Jul 2024 06:15:20 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2320319.1720791744.1@sss.pgh.pa.us> Date: Fri, 12 Jul 2024 09:42:24 -0400 Message-ID: <2320320.1720791744@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > On Thursday, July 11, 2024, PG Doc comments form > wrote: >> In this section nothing mentioned that a savepoint (a subtransaction) will >> not work inside plpgsql. > Correct, we prefer to just document how things work. 43.2 does mention > that blocks form subtransactions. It probably would be reasonable to mention something about this in 43.8, if only to provide an excuse to cross-reference 43.6.8. I'm imagining more or less PL/pgSQL does not support savepoints (SAVEPOINT/ROLLBACK TO SAVEPOINT/RELEASE SAVEPOINT commands). Typical usage patterns for savepoints can be replaced by blocks with exception handlers (see 43.6.8). I also notice the last para A transaction cannot be ended inside a block with exception handlers. which seems like it could be tied into that somehow. Maybe eliminate that as a separate para, and write PL/pgSQL does not support savepoints (SAVEPOINT/ROLLBACK TO SAVEPOINT/RELEASE SAVEPOINT commands). Typical usage patterns for savepoints can be replaced by blocks with exception handlers (see 43.6.8). Under the hood, a block with exception handlers forms a subtransaction, which means that transactions cannot be ended inside such a block. regards, tom lane