Re: Trigger behaviour not as stated

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: "Ian R(dot) Campbell" <ian(dot)campbell(at)thepathcentral(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>, ian(at)thepathcentral(dot)com, pgsql-docs(at)postgresql(dot)org, Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
Subject: Re: Trigger behaviour not as stated
Date: 2018-01-29 15:28:32
Message-ID: 20180129152832.GA11613@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Mon, Jan 29, 2018 at 11:32:34AM +0000, Ian R. Campbell wrote:
> The second part of the confusion is that INSERT is not considered to be a row
> modification and will fire a BEFORE INSERT trigger on the parent table even
> when the data goes into a child (whereas UPDATE and DELETE will not fire a
> parent trigger).

Ian, that is not true based on my testing. Running that attached script
that I already posted shows:

test=> INSERT INTO parent VALUES (1, 'one');
NOTICE: Called by parent INSERT
INSERT 0 1
test=> INSERT INTO child VALUES (2, 'two');
--> NOTICE: Called by child INSERT
INSERT 0 1

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +

Attachment Content-Type Size
trigger.sql application/x-sql 970 bytes

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message PG Doc comments form 2018-01-29 21:52:46 SPI not defined.
Previous Message Ian R. Campbell 2018-01-29 11:32:34 Re: Trigger behaviour not as stated