Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ksqPF-0000zw-QI for pgsql-general@arkaria.postgresql.org; Fri, 25 Dec 2020 16:57:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ksqPE-0001sE-PH for pgsql-general@arkaria.postgresql.org; Fri, 25 Dec 2020 16:57:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ksqPE-0001s6-HY for pgsql-general@lists.postgresql.org; Fri, 25 Dec 2020 16:57:32 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ksqP6-0001tH-Gu for pgsql-general@lists.postgresql.org; Fri, 25 Dec 2020 16:57:29 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 0BPGvLON1160653; Fri, 25 Dec 2020 11:57:21 -0500 From: Tom Lane To: Adrian Klaver cc: Andreas Joseph Krogh , pgsql-general@lists.postgresql.org Subject: Re: How to specify that a trigger should fire when column is NOT in SET-clause? In-reply-to: References: Comments: In-reply-to Adrian Klaver message dated "Fri, 25 Dec 2020 08:48:39 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1160651.1608915441.1@sss.pgh.pa.us> Date: Fri, 25 Dec 2020 11:57:21 -0500 Message-ID: <1160652.1608915441@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Adrian Klaver writes: > On 12/25/20 5:52 AM, Andreas Joseph Krogh wrote: >> Or - is it possible to check for this in the trigger-function? > As David Johnson mentioned you can check whether the value for the > column is changed: > NEW.animal <> OLD.animal Better to use IS DISTINCT FROM, to get sane behavior when one or the other value is NULL. regards, tom lane