Skip site navigation (1) Skip section navigation (2)

PL/pgSQL return value in after triggers

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: PL/pgSQL return value in after triggers
Date: 2011-02-28 17:07:16
Message-ID: 1298912836.26119.9.camel@vanquo.pezone.net (view raw or flat)
Thread:
Lists: pgsql-hackers
PL/pgSQL trigger functions currently require a value to be returned,
even though that value is not used for anything in case of a trigger
fired AFTER.  I was wondering if we could relax that.  It would make
things a bit more robust and produce clearer PL/pgSQL code.  The
specific case I'm concerned about is that a trigger function could
accidentally be run in a BEFORE trigger even though it was not meant for
that.  It is common practice that trigger functions for AFTER triggers
return NULL, which would have unpleasant effects if used in a BEFORE
trigger.

I think it is very uncommon to have the same function usable for BEFORE
and AFTER triggers, so it would be valuable to have coding support
specifically for AFTER triggers.  We could just allow RETURN without
argument, or perhaps no RETURN at all.

Comments?



Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2011-02-28 17:08:48
Subject: Re: pl/python custom exceptions for SPI
Previous:From: Robert HaasDate: 2011-02-28 17:01:31
Subject: Re: knngist - 0.8

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group