Functions and transactions

Started by Giorgio Valotiabout 18 years ago2 messagesgeneral
Jump to latest
#1Giorgio Valoti
giorgio_v@mac.com

Hi all, the documentation says that functions are always executed
within the transaction established by the outer query. However, I was
quite surprised (in a positive way, that is) seeing that if a
function call causes some error, the whole function is "rolled back".
Is this the expected behavior?

Thank you
--
Giorgio Valoti

#2Martijn van Oosterhout
kleptog@svana.org
In reply to: Giorgio Valoti (#1)
Re: Functions and transactions

On Tue, Apr 08, 2008 at 03:44:47PM +0200, Giorgio Valoti wrote:

Hi all, the documentation says that functions are always executed
within the transaction established by the outer query. However, I was
quite surprised (in a positive way, that is) seeing that if a
function call causes some error, the whole function is "rolled back".
Is this the expected behavior?

Yes. Just like errors in queries cause the transaction to be rolled
back. Mind you, inside functions you can trap errors, but the default
is to rollback everything in the current transaction.

Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

Show quoted text

Please line up in a tree and maintain the heap invariant while
boarding. Thank you for flying nlogn airlines.