Re: How to insert in a table the error returns by query

Поиск
Список
Период
Сортировка
От David G Johnston
Тема Re: How to insert in a table the error returns by query
Дата
Msg-id CAKFQuwY0NuNk4h5=JBboo8+TU=TpBFEXn43E-GMUi4mhyYiSjw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: How to insert in a table the error returns by query  (Marc Mamin <M.Mamin@intershop.de>)
Ответы Re: How to insert in a table the error returns by query
Список 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 по дате отправления:

Предыдущее
От: Marc Mamin
Дата:
Сообщение: Re: How to insert in a table the error returns by query
Следующее
От: Marc Mamin
Дата:
Сообщение: Re: How to insert in a table the error returns by query