Re: Trigger behaviour not as stated

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: 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-28 10:19:47
Message-ID: CAEepm=1cAO8y4dFv_xd=43iP7f4T3A2hYAzjgjQagHtt7H87Fw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Thu, Jan 25, 2018 at 11:07 AM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> On Wed, Jan 24, 2018 at 01:10:08PM -0500, Bruce Momjian wrote:
>> On Wed, Nov 29, 2017 at 07:39:34PM +0000, ian(at)thepathcentral(dot)com wrote:
>> > The following documentation comment has been logged on the website:
>> >
>> > Page: https://www.postgresql.org/docs/10/static/sql-createtrigger.html
>> > Description:
>> >
>> > URL: https://www.postgresql.org/docs/current/static/sql-createtrigger.html
>> >
>> > Statement: &quot;In contrast, row-level triggers are fired for all affected
>> > partitions or child tables.&quot;
>> >
>> > Row-level triggers are not fired on child tables where the trigger ON BEFORE
>> > UPDATE | DELETE is on the parent table. Only works on BEFORE INSERT.
>
> OK, I have some more details on this. First there is the Stackoverflow
> report:
>
> https://stackoverflow.com/questions/47557665/postgresql-on-before-delete-trigger-not-firing-on-a-parent-table-in-an-inheritan
>
> The report confirms that row-level triggers are fired _only_ on affected
> tables (meaning the table that had a row change), not on any table
> mentioned _or_ affected. The current wording, added in this commit:
>
> commit 501ed02cf6f4f60c3357775eb07578aebc912d3a
> Author: Andrew Gierth <rhodiumtoad(at)postgresql(dot)org>
> Date: Wed Jun 28 18:55:03 2017 +0100
>
> Fix transition tables for partition/inheritance.
>
> We disallow row-level triggers with transition tables on child tables.
> Transition tables for triggers on the parent table contain only those
> columns present in the parent. (We can't mix tuple formats in a
> single transition table.)
>
> Patch by Thomas Munro
>
> Discussion: https://postgr.es/m/CA%2BTgmoZzTBBAsEUh4MazAN7ga%3D8SsMC-Knp-6cetts9yNZUCcg%40mail.gmail.com
>
> should be improved. The attached patch updates the docs to say
> statement-level triggers fire on the "referenced" table, while row-level
> triggers fire only on the "affected" table, (vs. all affected tables)
> even if they are not referenced in the query. I would backpatch this to
> PG 10.

+1

I was trying to convey that, but it does seem a little terse and
cryptic. Your addition of "referenced" and "only" make it clearer.

--
Thomas Munro
http://www.enterprisedb.com

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Tom Lane 2018-01-28 19:18:38 Re: Trigger behaviour not as stated
Previous Message Bruce Momjian 2018-01-27 15:05:43 Re: pg_upgrade docs are confusing if PostgreSQL's versioning system/language isn't known to reader