Re: Nested Stored Procedures - ERROR: invalid transaction termination 2D000

From: Christophe Pettus <xof(at)thebuild(dot)com>
To: Kevin Stephenson <kjs714(at)hotmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Nested Stored Procedures - ERROR: invalid transaction termination 2D000
Date: 2025-03-22 09:01:51
Message-ID: 12B83964-7B3B-4345-9952-F8FE61727CB5@thebuild.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

> On Mar 22, 2025, at 08:38, Kevin Stephenson <kjs714(at)hotmail(dot)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 so raises the error you saw. This includes procedures that are called from within an exception block.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Christoph Berg 2025-03-22 09:43:00 Re: query_id: jumble names of temp tables for better pg_stat_statement UX
Previous Message Kevin Stephenson 2025-03-22 08:38:09 Nested Stored Procedures - ERROR: invalid transaction termination 2D000