Re: Supported plpgsql BEFORE ... EACH ROW behavior - Mailing list pgsql-general

From Richard Huxton
Subject Re: Supported plpgsql BEFORE ... EACH ROW behavior
Date
Msg-id 45DE9FCD.6030306@archonet.com
Whole thread Raw
In response to Supported plpgsql BEFORE ... EACH ROW behavior  ("Karl O. Pinc" <kop@meme.com>)
Responses Re: Supported plpgsql BEFORE ... EACH ROW behavior  ("Karl O. Pinc" <kop@meme.com>)
List pgsql-general
Karl O. Pinc wrote:
> Hi,
>
> I want to write a plpgsql function for use as a
> BEFORE ... EACH ROW function.  I want to modify
> other tables even when the function returns NULL
> and therefore the table on which the BEFORE
> trigger is defined is not updated.

> Sorry for being paranoid about this but I
> want to double check before relying on
> behavior that few people probably use.

I think it's fairly common, actually. Returning NULL is cancelling the
update *of that row* rather than aborting the transaction, so all
side-effects should always survive.

Otherwise you couldn't update 100 rows and just skip one or two by
returning NULL from a before trigger.

--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: Marek Lewczuk
Date:
Subject: Re: Warning "TupleDesc reference leak"
Next
From: Richard Huxton
Date:
Subject: Re: Large Objects