Re: Nested Stored Procedures - ERROR: invalid transaction termination 2D000 - Mailing list pgsql-general

From Christophe Pettus
Subject Re: Nested Stored Procedures - ERROR: invalid transaction termination 2D000
Date
Msg-id 12B83964-7B3B-4345-9952-F8FE61727CB5@thebuild.com
Whole thread Raw
In response to Nested Stored Procedures - ERROR: invalid transaction termination 2D000  (Kevin Stephenson <kjs714@hotmail.com>)
Responses Re: Nested Stored Procedures - ERROR: invalid transaction termination 2D000
List pgsql-general
Hello,

> On Mar 22, 2025, at 08:38, Kevin Stephenson <kjs714@hotmail.com> wrote:
>     • When a top-level stored procedure is called it implicitly creates a TX if there is no current TX.
>     • When a BEGIN/EXCEPTION block is used it implicitly creates a subTX for that block.

These statements are correct.

>     • When a nested stored procedure is called it implicitly creates a subTX for that invocation.

This one is not.  (Although the behavior you are looking for may not depend on that.)

A procedure cannot issue top-level transaction control statements from within an exception block, and attempting to do
soraises the error you saw.  This includes procedures that are called from within an exception block. 


pgsql-general by date:

Previous
From: Kevin Stephenson
Date:
Subject: Nested Stored Procedures - ERROR: invalid transaction termination 2D000
Next
From: Tom Lane
Date:
Subject: Re: Nested Stored Procedures - ERROR: invalid transaction termination 2D000