public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tom Lane <[email protected]>
To: Christophe Pettus <[email protected]>
Cc: Kevin Stephenson <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: Nested Stored Procedures - ERROR: invalid transaction termination 2D000
Date: Sat, 22 Mar 2025 21:12:05 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <IA0PR19MB721723603709836EE5D0B17E8FDA2@IA0PR19MB7217.namprd19.prod.outlook.com>
<[email protected]>
<[email protected]>
<IA0PR19MB7217A4E99BAAB1FDF576AC738FDA2@IA0PR19MB7217.namprd19.prod.outlook.com>
<[email protected]>
Christophe Pettus <[email protected]> writes:
> That's an interesting question. It appears to be a no-op, although a quick scan of the code doesn't reveal why. Here's an illustrative test case:
This test case would be less confusing if the outer handler did
RAISE NOTICE 'in outer exception handler: %', sqlerrm;
With that, the test shows
regression=# call outer();
NOTICE: in outer exception handler: invalid transaction termination
CALL
What is happening is that inner() does PERFORM 1/0, fails and bounces
out to its exception handler, and then the ROLLBACK throws an error
because we're still inside outer()'s subtransaction. So inner()'s
first INSERT has been rolled back and the second one is never
reached. Back at outer()'s exception handler, we trap the error
from ROLLBACK, abort that subtransaction, and go on our merry way,
allowing the original INSERT (which was outside both subtransactions)
to complete.
regards, tom lane
view thread (6+ messages)
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: <[email protected]>
* 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