Determining if a table really changed in a trigger

Поиск
Список
Период
Сортировка
От Mitar
Тема Determining if a table really changed in a trigger
Дата
Msg-id CAKLmikNjiz=zwf9suiAHoBLrRpjLTNsQ=f4PGD3RMFBxzR-3OA@mail.gmail.com
обсуждение исходный текст
Ответы Re: Determining if a table really changed in a trigger  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: Determining if a table really changed in a trigger  (Marcos Pegoraro <marcos@f10.com.br>)
Re: Determining if a table really changed in a trigger  (Alban Hertroys <haramrae@gmail.com>)
Re: Determining if a table really changed in a trigger  (Mitar <mmitar@gmail.com>)
Re: Determining if a table really changed in a trigger  (Mark Dilger <mark.dilger@enterprisedb.com>)
Re: Determining if a table really changed in a trigger  (Thomas Kellerer <shammat@gmx.net>)
Список pgsql-general
Hi!

I have a trigger like:

CREATE TRIGGER update_trigger AFTER UPDATE ON my_table REFERENCING NEW
TABLE AS new_table OLD TABLE AS old_table FOR EACH STATEMENT EXECUTE
FUNCTION trigger_function;

I would like to test inside trigger_function if the table really
changed. I have tried to do:

PERFORM * FROM ((TABLE old_table EXCEPT TABLE new_table) UNION ALL
(TABLE new_table EXCEPT TABLE old_table)) AS differences LIMIT 1;
IF FOUND THEN
  ... changed ...
END IF;

But this fails if the table contains a JSON field with the error:

could not identify an equality operator for type json

The table has an unique index column, if that helps.


Mitar

-- 
http://mitar.tnode.com/
https://twitter.com/mitar_m



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

Предыдущее
От: Vivekk P
Дата:
Сообщение: Need recommendation on PARALLEL INDEX SCAN and PARALLEL APPEND
Следующее
От: Vijaykumar Jain
Дата:
Сообщение: Re: Need recommendation on PARALLEL INDEX SCAN and PARALLEL APPEND