Re: Determining if a table really changed in a trigger - Mailing list pgsql-general

From David G. Johnston
Subject Re: Determining if a table really changed in a trigger
Date
Msg-id CAKFQuwb+iOAkzhCRnGZcVdC0yQZ1FQVWBuxupRgQna2d9yAuBw@mail.gmail.com
Whole thread Raw
In response to Determining if a table really changed in a trigger  (Mitar <mmitar@gmail.com>)
List pgsql-general
On Tue, Oct 26, 2021 at 12:05 AM Mitar <mmitar@gmail.com> wrote:

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

could not identify an equality operator for type json

Thus it is not possible to use whole row comparisons.  You will need to write the code to manually check equality on each column.  To check the json column you will probably want to cast to jsonb (if it isn't already) and then cast that to text and use a text equality check.  Since you are doing a statement trigger that means writing "SELECT col1, col2, etc...".


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


That would be assumed since you need to be able to identify records whose contents might otherwise be identical.

David J.

pgsql-general by date:

Previous
From: E-BLOKOS
Date:
Subject: Re: ZFS filesystem - supported ?
Next
From: "David G. Johnston"
Date:
Subject: Re: How to copy rows into same table efficiently