Re: How to insert in a table the error returns by query - Mailing list pgsql-sql

From David G Johnston
Subject Re: How to insert in a table the error returns by query
Date
Msg-id CAKFQuwY0NuNk4h5=JBboo8+TU=TpBFEXn43E-GMUi4mhyYiSjw@mail.gmail.com
Whole thread Raw
In response to Re: How to insert in a table the error returns by query  (Marc Mamin <M.Mamin@intershop.de>)
Responses Re: How to insert in a table the error returns by query
List pgsql-sql
On Wed, Jan 28, 2015 at 11:53 AM, Marc Mamin-2 [via PostgreSQL] <[hidden email]> wrote:

>In this case when an error occurs the rollback work only on the wrong query. The other insert are committed.


The rollback only takes place on the errored statement, because you are catching the exception.
In order to ensure a complete rollback of your transaction (which may have started outside of your function),
you'll need to rethrow an error after your exception handling.


​The 9.4 documentation is in direct conflict with this statement...all persistent updates inside the associated BEGIN/END block should be rolled back.

Transactions MUST start "outside your function" by definition.  By not re-throwing the exception any outer block (i.e., the one calling the function) would still end up intact but every statement inside of the function should rollback unless separate blocks are created to isolate the different statements.

David J.


View this message in context: Re: How to insert in a table the error returns by query
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.

pgsql-sql by date:

Previous
From: Marc Mamin
Date:
Subject: Re: How to insert in a table the error returns by query
Next
From: Marc Mamin
Date:
Subject: Re: How to insert in a table the error returns by query