Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fTg0T-0003nf-4N for pgsql-general@arkaria.postgresql.org; Fri, 15 Jun 2018 04:06:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fTg0R-0007Wn-7f for pgsql-general@arkaria.postgresql.org; Fri, 15 Jun 2018 04:06:35 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fTg0Q-0007Wd-R7 for pgsql-general@lists.postgresql.org; Fri, 15 Jun 2018 04:06:35 +0000 Received: from wolff.to ([98.103.208.27]) by makus.postgresql.org with smtp (Exim 4.89) (envelope-from ) id 1fTg0J-0004tH-Vx for pgsql-general@postgresql.org; Fri, 15 Jun 2018 04:06:33 +0000 Received: (qmail 19907 invoked by uid 500); 15 Jun 2018 04:04:24 -0000 Date: Thu, 14 Jun 2018 23:04:24 -0500 From: Bruno Wolff III To: pgsql-general@postgresql.org Subject: Trying to understand odd trigger behavior Message-ID: <20180615040424.GA18759@wolff.to> Mail-Followup-To: Bruno Wolff III , pgsql-general@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline User-Agent: Mutt/1.10.0 (2018-05-17) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I think I know what is happening, but I wanted to see if my understanding is correct. I have a perl after insert trigger for a table with a non-null column element and I am getting an occasional error when the trigger executes for printing a null value which is $TD->{new}{element}. However, I do the insert with an on conflict that converts it into an update. And I have a before update trigger that blocks changing the record, but returns null if the old and new records are the same. My theory is that the insert trigger is firing even though the action got changed to an update and that because the update trigger cancelled the update, there is no new record. So I should just test for $TD->{new} being doing before doing stuff. Does that sound correct?