From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: AFTER triggers & RETURN |
Date: | 2009-11-06 01:10:19 |
Message-ID: | 603c8f070911051710y7e43ef1bqf431a132bdc83eb1@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Nov 5, 2009 at 4:57 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>> Robert Haas wrote:
>>> Since the return value is ignored anyway, why do we have to complain
>>> if it's left out altogether? Granted, it's easy to work around, but
>>> still.
>
>> Isn't is a requirement of plpgsql that you not fall off the end of a
>> function unless it is declared to return void? The function doesn't know
>> if it will be called before or after.
>
> Yeah, it couldn't be done as a compile-time check. You could probably
> make it work if you converted the error to a run-time test. Not sure
> if that's really an improvement though.
Well, as it is, you don't get an error when you define the function,
only when you do something that causes it to be invoked. An error
when you define the function would probably be a small improvement,
because at least it would be obvious that you'd broke something (and
the transaction that tried to break it would roll back). No error at
all seems better still.
Perhaps in an ideal world before and after trigger functions would
have different signatures - like the before trigger should perhaps
take two rows as arguments and return a row, and the after trigger
should take two rows as arguments and return void. The idea of
overloading the function's return type to provide it with special,
magical input parameters is pretty funky and means that you can't
invoke that function in any context other than as a trigger, which
would occasionally be useful. I think we're stuck with it at this
point, but maybe it's possible to at least relax the requirement to
explicitly return a useless result.
...Robert
From | Date | Subject | |
---|---|---|---|
Next Message | abindra | 2009-11-06 02:30:11 | Freebsd & autoconf-2.63 |
Previous Message | Robert Haas | 2009-11-06 01:03:25 | Re: Why do OLD and NEW have special internal names? |