public inbox for [email protected]
help / color / mirror / Atom feedFrom: Kevin Stephenson <[email protected]>
To: Tom Lane <[email protected]>
To: Christophe Pettus <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: Nested Stored Procedures - ERROR: invalid transaction termination 2D000
Date: Sat, 22 Mar 2025 21:37:53 +0000
Message-ID: <IA0PR19MB7217A4E99BAAB1FDF576AC738FDA2@IA0PR19MB7217.namprd19.prod.outlook.com> (raw)
In-Reply-To: <[email protected]>
References: <IA0PR19MB721723603709836EE5D0B17E8FDA2@IA0PR19MB7217.namprd19.prod.outlook.com>
<[email protected]>
<[email protected]>
Christophe and Tom, thank you for your responses, but I'm still a bit confused. In my original email, the Test 2 case is allowing a ROLLBACK in the EXCEPTION clause without throwing an error. Is it a NOP ROLLBACK being applied to an aborted subTX, a real full ROLLBACK, or something else? Please advise.
Thanks,
Kevin Stephenson
________________________________
From: Tom Lane <[email protected]>
Sent: Saturday, March 22, 2025 7:59 AM
To: Christophe Pettus <[email protected]>
Cc: Kevin Stephenson <[email protected]>; [email protected] <[email protected]>
Subject: Re: Nested Stored Procedures - ERROR: invalid transaction termination 2D000
Christophe Pettus <[email protected]> writes:
> 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.
Yeah. Postgres doesn't have autonomous transactions (not yet anyway),
and you can't fake them like that.
A way that does work, I believe, is to set up a second session with
dblink[1] and use that to issue the autonomous transaction. Ugly
and inefficient for sure, but if you've gotta have it...
regards, tom lane
[1] https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.postgresql.org%2Fdocs%2Fcurrent...;
view thread (6+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Nested Stored Procedures - ERROR: invalid transaction termination 2D000
In-Reply-To: <IA0PR19MB7217A4E99BAAB1FDF576AC738FDA2@IA0PR19MB7217.namprd19.prod.outlook.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox