Re: Rules: passing new/old to functions

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Rules: passing new/old to functions
Дата
Msg-id 24557.1056685762@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Rules: passing new/old to functions  (Gunter Diehl <gdid@gmx.de>)
Список pgsql-sql
Gunter Diehl <gdid@gmx.de> writes:
> create funtion f1(v, v) returns void as '...'
> create rule vupt as on update to v do instead select f1(new, old)
> While accepting this definitions, pg says it can not handle "whole-tuple
> references" at runtime.

FWIW, the "old" case works fine.  "new" doesn't work so well because the
new row hasn't been formed into a tuple at the point where the rule
runs; it only exists as a list of variables.  (This is a rather handwavy
explanation, but I think it captures the key point.)  While this could
probably be fixed with some effort, I doubt it's going to happen soon.
Is there any chance of doing what you want with a trigger instead of a
rule?
        regards, tom lane


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

Предыдущее
От: Ian Barwick
Дата:
Сообщение: Re: UPDATE table SET col = (SELECT ...)
Следующее
От: "Nicolas JOUANIN"
Дата:
Сообщение: Re: TR: Like and =