Re: Nested Stored Procedures - ERROR: invalid transaction termination 2D000

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Nested Stored Procedures - ERROR: invalid transaction termination 2D000
Дата
Msg-id 462135.1742692325@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Nested Stored Procedures - ERROR: invalid transaction termination 2D000  (Christophe Pettus <xof@thebuild.com>)
Список pgsql-general
Christophe Pettus <xof@thebuild.com> 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'san 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



В списке pgsql-general по дате отправления: