| From: | Mitar <mmitar(at)gmail(dot)com> |
|---|---|
| To: | Postgres General <pgsql-general(at)postgresql(dot)org> |
| Subject: | Determining if a table really changed in a trigger |
| Date: | 2021-10-26 07:05:06 |
| Message-ID: | CAKLmikNjiz=zwf9suiAHoBLrRpjLTNsQ=f4PGD3RMFBxzR-3OA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Vijaykumar Jain | 2021-10-26 07:18:15 | Re: Need recommendation on PARALLEL INDEX SCAN and PARALLEL APPEND |
| Previous Message | Vivekk P | 2021-10-26 06:09:01 | Need recommendation on PARALLEL INDEX SCAN and PARALLEL APPEND |