Re: PostgreSQL trigger how to detect a column value explicitely modified

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: PostgreSQL trigger how to detect a column value explicitely modified
Дата
Msg-id 518934.1762268889@sss.pgh.pa.us
обсуждение исходный текст
Ответ на PostgreSQL trigger how to detect a column value explicitely modified  (PALAYRET Jacques <jacques.palayret@meteo.fr>)
Список pgsql-general
PALAYRET Jacques <jacques.palayret@meteo.fr> writes:
> In a trigger body, is there a simple way to know if a column value has been explicitely modified ?
> Explicitely modified ; in others words, typically indicated in the SET clause of the UPDATE.

I believe that an ON UPDATE trigger coded in C can access a bitmapset
that shows which column(s) are targeted in the SET clause; but we've
not exposed that to PL/pgSQL or other higher-level languages.

There are of course a bunch of definitional issues.  Should
"UPDATE ... SET x = x" count as an update?  What if some earlier
(... or later ...) BEFORE trigger changes a column?  We don't
provide any help for those cases either.

I think most people settle for testing "OLD.col IS DISTINCT FROM
NEW.col", which you could argue is a good operational definition
of whether the column changed.

            regards, tom lane



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