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 1i8qwB-0004Qc-7H for pgsql-general@arkaria.postgresql.org; Fri, 13 Sep 2019 19:08:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i8qwA-0001s0-4a for pgsql-general@arkaria.postgresql.org; Fri, 13 Sep 2019 19:08:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i8qw9-0001ro-OA for pgsql-general@lists.postgresql.org; Fri, 13 Sep 2019 19:08:53 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1i8qw7-00043y-J9 for pgsql-general@lists.postgresql.org; Fri, 13 Sep 2019 19:08:52 +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 x8DJ8njo021220; Fri, 13 Sep 2019 15:08:49 -0400 From: Tom Lane To: Judy Loomis cc: pgsql-general@lists.postgresql.org Subject: Re: Cascade Trigger Not Firing In-reply-to: References: Comments: In-reply-to Judy Loomis message dated "Fri, 13 Sep 2019 14:03:45 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <21218.1568401729.1@sss.pgh.pa.us> Date: Fri, 13 Sep 2019 15:08:49 -0400 Message-ID: <21219.1568401729@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Judy Loomis writes: > I have a trigger that updates a target column when some other columns > change. > There is another trigger on the target column to update another table (the > column can be changed in other ways besides the first trigger). > If I update the target column directly the expected trigger fires. > But if the 1st trigger changes the target column and it wasn't in the list > of updated columns, the 2nd trigger doesn't fire. > Is this expected behavior? Per the manual (NOTES section of the CREATE TRIGGER man page): A column-specific trigger (one defined using the UPDATE OF column_name syntax) will fire when any of its columns are listed as targets in the UPDATE command's SET list. It is possible for a column's value to change even when the trigger is not fired, because changes made to the row's contents by BEFORE UPDATE triggers are not considered. Conversely, a command such as UPDATE ... SET x = x ... will fire a trigger on column x, even though the column's value did not change. It's not really practical for trigger firings to depend on what other triggers did or might do --- you'd soon end up with circularities. regards, tom lane