Re: COMMIT IN STORED PROCEDURE WHILE IN A LOOP - Mailing list pgsql-general

From Christophe Pettus
Subject Re: COMMIT IN STORED PROCEDURE WHILE IN A LOOP
Date
Msg-id 408C4DF8-2F05-401A-B4BC-FAAAFE79CA49@thebuild.com
Whole thread Raw
In response to Re: COMMIT IN STORED PROCEDURE WHILE IN A LOOP  (Bryn Llewellyn <bryn@yugabyte.com>)
List pgsql-general

> On Oct 18, 2022, at 14:15, Bryn Llewellyn <bryn@yugabyte.com> wrote:
> Could the limitation be lifted by making tractable internal implementation changes? Or is it rooted in profoundly
deepfeatures of the architecture—meaning that it could never be lifted? 

That is a very good question.  One of the issues (as I understand it) is to be able to continue to use the same
connectionin the event of an error.  Here's the scenario: 

1. SELECT * FROM my_func();

2. my_func gets an error.  The connection is now in an error state.

3. So, catching the exception doesn't do you much good, because future operations will get an error.

This problem is solved by wrapping it in a savepoint, since rolling back to the savepoint will undo the error state of
theconnection. 

There might be a way forward, but it's hard to get the proper semantics of an exception handler without doing something
likethat.  


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: COMMIT IN STORED PROCEDURE WHILE IN A LOOP
Next
From: Ted Toth
Date:
Subject: what's inherited