Обсуждение: Rollback for aborted function?

Поиск
Список
Период
Сортировка

Rollback for aborted function?

От
Rory Campbell-Lange
Дата:
If a function generates an exception, do I need to rollback manually?

--
Rory Campbell-Lange
<rory@campbell-lange.net>
<www.campbell-lange.net>

Re: Rollback for aborted function?

От
"scott.marlowe"
Дата:
On Thu, 3 Jul 2003, Rory Campbell-Lange wrote:

> If a function generates an exception, do I need to rollback manually?

Not currently.  The current bevaviour of postgresql is to roll back any
transaction that generates an error.  Of course, it's considered good
practice to do it in some circles.  And someday there will be sub
transactions, which would let you just enclose possible sticking points in
your transaction in its own box.

But even then, my guess is that as soon as the connection is lost, or you
try to commit without handling the errors (in some not too distant future
with subtrans / error handling) then the transaction will roll back
anyway.


Re: Rollback for aborted function?

От
Richard Huxton
Дата:
On Thursday 03 Jul 2003 3:39 pm, Rory Campbell-Lange wrote:
> If a function generates an exception, do I need to rollback manually?

No - any error will abort a transaction.
In fact, you can't stop it happening - trapping errors is one of the more
common feature requests - possibly available in 7.5, not in the forthcoming
7.4.

--
  Richard Huxton