Re: Supported plpgsql BEFORE ... EACH ROW behavior

From: Richard Huxton <dev(at)archonet(dot)com>
To: "Karl O(dot) Pinc" <kop(at)meme(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Supported plpgsql BEFORE ... EACH ROW behavior
Date: 2007-02-23 08:03:25
Message-ID: 45DE9FCD.6030306@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2007-02-23 08:06:25 Re: Large Objects
Previous Message Marek Lewczuk 2007-02-23 08:03:04 Re: Warning "TupleDesc reference leak"