Re: "A transaction cannot be ended inside a block with exception handlers." - Mailing list pgsql-general

From David G. Johnston
Subject Re: "A transaction cannot be ended inside a block with exception handlers."
Date
Msg-id CAKFQuwbjWf2FTUruGzhx--f74ctw0MRLf_DwBXk0JO1LMnLx_A@mail.gmail.com
Whole thread Raw
In response to "A transaction cannot be ended inside a block with exception handlers."  (Bryn Llewellyn <bryn@yugabyte.com>)
Responses Re: "A transaction cannot be ended inside a block with exception handlers."
List pgsql-general
On Fri, May 6, 2022 at 4:40 PM Bryn Llewellyn <bryn@yugabyte.com> wrote:

Is there simply no way that inserts into table "t" in my example can be encapsulated in PL/pgSQL so that the error from the failing trigger can be handled rather there than escaping, raw, to the client?


Any potential solution to this problem will involve writing a stored procedure (CREATE PROCEDURE) which becomes the API layer for the application and each one probably issues a commit just prior to returning control to the calling application.  Its exception handler can transform the at-commit errors to application errors and then return control to the calling application - which then needs to handle a clean return or an application-level error return.

David J.

pgsql-general by date:

Previous
From: Bryn Llewellyn
Date:
Subject: "A transaction cannot be ended inside a block with exception handlers."
Next
From: Rama Krishnan
Date:
Subject: Vertical partition