Re: Functions and transactions

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Giorgio Valoti <giorgio_v(at)mac(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Functions and transactions
Date: 2008-04-08 13:53:57
Message-ID: 20080408135357.GD31397@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(at)svana(dot)org> http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Gordon 2008-04-08 14:03:07 Determining weather a query fired a trigger
Previous Message Tom Lane 2008-04-08 13:52:37 Re: Trouble getting effective_cache_size parameter to take