Re: AFTER triggers & RETURN

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: AFTER triggers & RETURN
Дата
Msg-id 603c8f070911051710y7e43ef1bqf431a132bdc83eb1@mail.gmail.com
обсуждение исходный текст
Ответ на Re: AFTER triggers & RETURN  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: AFTER triggers & RETURN
Список pgsql-hackers
On Thu, Nov 5, 2009 at 4:57 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Andrew Dunstan <andrew@dunslane.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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: Why do OLD and NEW have special internal names?
Следующее
От: abindra@u.washington.edu
Дата:
Сообщение: Freebsd & autoconf-2.63