Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8sii-0000L5-5q for pgsql-general@arkaria.postgresql.org; Fri, 13 Sep 2019 21:03:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i8sih-0002GQ-3D for pgsql-general@arkaria.postgresql.org; Fri, 13 Sep 2019 21:03:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8sig-0002GG-Po for pgsql-general@lists.postgresql.org; Fri, 13 Sep 2019 21:03:06 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8sie-0007at-RT for pgsql-general@lists.postgresql.org; Fri, 13 Sep 2019 21:03:06 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x8DL310D020934; Fri, 13 Sep 2019 17:03:01 -0400 From: Tom Lane To: Judy Loomis cc: pgsql-general@lists.postgresql.org Subject: Re: Cascade Trigger Not Firing In-reply-to: References: <21219.1568401729@sss.pgh.pa.us> Comments: In-reply-to Judy Loomis message dated "Fri, 13 Sep 2019 14:12:26 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <20932.1568408581.1@sss.pgh.pa.us> Date: Fri, 13 Sep 2019 17:03:01 -0400 Message-ID: <20933.1568408581@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Judy Loomis writes: > I'm going to have to really look at all my BEFORE UPDATE triggers and make > sure we're not missing any more. > And I have to stop telling management that a trigger means we always know > when a value changes. Well, you can rely on that, just not like this. Use an AFTER trigger (else, you can't be sure it fires after all the BEFORE triggers) and instead of triggering it with a column parameter, have it do something like "if old.col is distinct from new.col". Yeah, it's a bit slower that way, but there's no free lunch, especially if you don't trust your other triggers. (Although, if you have so many triggers that that's a problem, I think you might have some other design issues.) regards, tom lane