Re: NEW.* and OLD.* inside trigger function don't seem to contain recently added columns

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: NEW.* and OLD.* inside trigger function don't seem to contain recently added columns
Дата
Msg-id 1218764.1711154512@sss.pgh.pa.us
обсуждение исходный текст
Ответ на NEW.* and OLD.* inside trigger function don't seem to contain recently added columns  (Janne Annala <janne.annala@forenom.com>)
Ответы Re: NEW.* and OLD.* inside trigger function don't seem to contain recently added columns  (Janne Annala <janne.annala@forenom.com>)
Список pgsql-bugs
Janne Annala <janne.annala@forenom.com> writes:
> Here's the minimum case to reproduce the issue:

> CREATE FUNCTION x()
>  RETURNS trigger
>  LANGUAGE plpgsql
> AS $function$
> BEGIN
>   IF ROW(NEW.*) IS DISTINCT FROM ROW(OLD.*) THEN

Try dropping the ROW() bit, that is just

   IF NEW.* IS DISTINCT FROM OLD.* THEN

or even

   IF NEW IS DISTINCT FROM OLD THEN

I think what is happening is that the ROW() notation is getting
expanded at parse time to

   ROW(NEW.id, NEW.old_column, NEW.updated)

and then there's no dependency on the original rowtype that would
lead to that expansion getting reconsidered.  Arguably that's a
bug, but it's not clear to me what the consequences of changing
that behavior would be.

            regards, tom lane



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

Предыдущее
От: Alexander Korotkov
Дата:
Сообщение: Re: [BUG] false positive in bt_index_check in case of short 4B varlena datum
Следующее
От: Peter Geoghegan
Дата:
Сообщение: Re: Index plan returns different results to sequential scan