pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples
8+ messages / 3 participants
[nested] [flat]

Commits from this thread:
  2020-06-25 81d46ea12c 257ee34e73 4a12bfe21a 9ac3b6f9d2 dd2bb77c72 441d4b5a37 08671057e0  doc:  mention trigger helper functions in CREATE TRIGGER docs
* Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples
@ 2020-06-12 09:09 PG Doc comments form <noreply@postgresql.org>
  2020-06-16 10:36 ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 8+ messages in thread

From: PG Doc comments form @ 2020-06-12 09:09 UTC (permalink / raw)
  To: pgsql-docs@lists.postgresql.org; +Cc: petermpallesen@gmail.com

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/12/bug-reporting.html
Description:

Hi 
I was stumbling across the trigger function
‘suppress_redundant_updates_trigger’ in
https://www.postgresql.org/docs/devel/functions-trigger.html and I would
just ask if there is any reason of this not being int the documentation in 
https://www.postgresql.org/docs/13/sql-createtrigger.html. 
So after

Call a function to log updates of accounts, but only if something changed:

CREATE TRIGGER log_update
    AFTER UPDATE ON accounts
    FOR EACH ROW
    WHEN (OLD.* IS DISTINCT FROM NEW.*)
    EXECUTE FUNCTION log_account_update();

There could be an alternative implementation as well

CREATE TRIGGER log_update
    AFTER UPDATE ON accounts
    FOR EACH ROW
    EXECUTE FUNCTION log_account_update();

CREATE TRIGGER suppress_redundant_account_after_updates
AFTER UPDATE ON accounts
FOR EACH ROW EXECUTE FUNCTION suppress_redundant_updates_trigger();


Just to introduce and like the feature.

Thank you for your great work best regards


^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples
  2020-06-12 09:09 Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples PG Doc comments form <noreply@postgresql.org>
@ 2020-06-16 10:36 ` Bruce Momjian <bruce@momjian.us>
  2020-06-16 14:08   ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 8+ messages in thread

From: Bruce Momjian @ 2020-06-16 10:36 UTC (permalink / raw)
  To: petermpallesen@gmail.com; pgsql-docs@lists.postgresql.org

On Fri, Jun 12, 2020 at 09:09:09AM +0000, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
> 
> Page: https://www.postgresql.org/docs/12/bug-reporting.html
> Description:
> 
> Hi 
> I was stumbling across the trigger function
> ‘suppress_redundant_updates_trigger’ in
> https://www.postgresql.org/docs/devel/functions-trigger.html and I would
> just ask if there is any reason of this not being int the documentation in 
> https://www.postgresql.org/docs/13/sql-createtrigger.html. 
> So after
> 
> Call a function to log updates of accounts, but only if something changed:
> 
> CREATE TRIGGER log_update
>     AFTER UPDATE ON accounts
>     FOR EACH ROW
>     WHEN (OLD.* IS DISTINCT FROM NEW.*)
>     EXECUTE FUNCTION log_account_update();
> 
> There could be an alternative implementation as well
> 
> CREATE TRIGGER log_update
>     AFTER UPDATE ON accounts
>     FOR EACH ROW
>     EXECUTE FUNCTION log_account_update();
> 
> CREATE TRIGGER suppress_redundant_account_after_updates
> AFTER UPDATE ON accounts
> FOR EACH ROW EXECUTE FUNCTION suppress_redundant_updates_trigger();
> 
> 
> Just to introduce and like the feature.
> 
> Thank you for your great work best regards

I have created the attached patch to mention
suppress_redundant_updates_trigger() in this case.  I don't think having
an actual example is warranted.

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EnterpriseDB                             https://enterprisedb.com

  The usefulness of a cup is in its emptiness, Bruce Lee

Attachments:

trigger.diff (text/x-diff, 544B) download diff --git a/doc/src/sgml/ref/create_trigger.sgml b/doc/src/sgml/ref/create_trigger.sgml index 303881fcfb..8cfac0fbc6 100644 --- a/doc/src/sgml/ref/create_trigger.sgml +++ b/doc/src/sgml/ref/create_trigger.sgml @@ -582,7 +582,9 @@ CREATE TRIGGER check_update </programlisting> Call a function to log updates of <literal>accounts</literal>, but only if - something changed: + something changed + (<function>suppress_redundant_updates_trigger()</function> can also be + helpful here): <programlisting> CREATE TRIGGER log_update
^ permalink raw reply [nested|flat] 8+ messages in thread

* Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples
  2020-06-12 09:09 Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples PG Doc comments form <noreply@postgresql.org>
  2020-06-16 10:36 ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Bruce Momjian <bruce@momjian.us>
@ 2020-06-16 14:08   ` Tom Lane <tgl@sss.pgh.pa.us>
  2020-06-16 16:41     ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 8+ messages in thread

From: Tom Lane @ 2020-06-16 14:08 UTC (permalink / raw)
  To: Bruce Momjian <bruce@momjian.us>; +Cc: petermpallesen@gmail.com; pgsql-docs@lists.postgresql.org

Bruce Momjian <bruce@momjian.us> writes:
> I have created the attached patch to mention
> suppress_redundant_updates_trigger() in this case.  I don't think having
> an actual example is warranted.

I don't like this patch, because in fact
suppress_redundant_updates_trigger is entirely unrelated to the stated
purpose of that example (namely, to log something if the table was
changed).  The way you've written it makes it sound like
suppress_redundant_updates_trigger could be used as an alternative
implementation of that requirement.

If you want to mention suppress_redundant_updates_trigger somewhere
in this area, that's fine, but it should be treated as an independent
topic rather than being wedged into the middle of an unrelated example.
Maybe a distinct para saying something like "To suppress no-op updates
of a table, see suppress_redundant_updates_trigger." (and making that
an actual link would be a good idea).

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples
  2020-06-12 09:09 Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples PG Doc comments form <noreply@postgresql.org>
  2020-06-16 10:36 ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Bruce Momjian <bruce@momjian.us>
  2020-06-16 14:08   ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Tom Lane <tgl@sss.pgh.pa.us>
@ 2020-06-16 16:41     ` Bruce Momjian <bruce@momjian.us>
  2020-06-16 17:39       ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 8+ messages in thread

From: Bruce Momjian @ 2020-06-16 16:41 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: petermpallesen@gmail.com; pgsql-docs@lists.postgresql.org

On Tue, Jun 16, 2020 at 10:08:14AM -0400, Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > I have created the attached patch to mention
> > suppress_redundant_updates_trigger() in this case.  I don't think having
> > an actual example is warranted.
> 
> I don't like this patch, because in fact
> suppress_redundant_updates_trigger is entirely unrelated to the stated
> purpose of that example (namely, to log something if the table was
> changed).  The way you've written it makes it sound like
> suppress_redundant_updates_trigger could be used as an alternative
> implementation of that requirement.

Ah,  I see your point.

> If you want to mention suppress_redundant_updates_trigger somewhere
> in this area, that's fine, but it should be treated as an independent
> topic rather than being wedged into the middle of an unrelated example.
> Maybe a distinct para saying something like "To suppress no-op updates
> of a table, see suppress_redundant_updates_trigger." (and making that
> an actual link would be a good idea).

I have developed the attached patch which is in a better direction.

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EnterpriseDB                             https://enterprisedb.com

  The usefulness of a cup is in its emptiness, Bruce Lee

Attachments:

trigger.diff (text/x-diff, 792B) download diff --git a/doc/src/sgml/ref/create_trigger.sgml b/doc/src/sgml/ref/create_trigger.sgml index 303881fcfb..7ef96c5650 100644 --- a/doc/src/sgml/ref/create_trigger.sgml +++ b/doc/src/sgml/ref/create_trigger.sgml @@ -454,7 +454,9 @@ UPDATE OF <replaceable>column_name1</replaceable> [, <replaceable>column_name2</ row's contents by <literal>BEFORE UPDATE</literal> triggers are not considered. Conversely, a command such as <literal>UPDATE ... SET x = x ...</literal> will fire a trigger on column <literal>x</literal>, even though the column's - value did not change. + value did not change; use function <link + linkend="functions-trigger"><function>suppress_redundant_updates_trigger</function></link> + in triggers to suppress non-change updates. </para> <para>
^ permalink raw reply [nested|flat] 8+ messages in thread

* Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples
  2020-06-12 09:09 Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples PG Doc comments form <noreply@postgresql.org>
  2020-06-16 10:36 ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Bruce Momjian <bruce@momjian.us>
  2020-06-16 14:08   ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Tom Lane <tgl@sss.pgh.pa.us>
  2020-06-16 16:41     ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Bruce Momjian <bruce@momjian.us>
@ 2020-06-16 17:39       ` Tom Lane <tgl@sss.pgh.pa.us>
  2020-06-16 17:49         ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 8+ messages in thread

From: Tom Lane @ 2020-06-16 17:39 UTC (permalink / raw)
  To: Bruce Momjian <bruce@momjian.us>; +Cc: petermpallesen@gmail.com; pgsql-docs@lists.postgresql.org

Bruce Momjian <bruce@momjian.us> writes:
> I have developed the attached patch which is in a better direction.

I still wish you wouldn't jam this topic into an only-marginally-related
sentence.  In the case at hand, the point that the existing text is
making is that a no-op update will fire triggers.  Which is not
something that suppress_redundant_updates_trigger will suppress,
so again it seems confusing to mention that in the same breath.

I think that perhaps the right thing to do is add a new para to
CREATE TRIGGER's "Notes" section, along the lines of

       There are a few built-in trigger functions that can be used
       to solve common problems without having to write your own trigger
       code.  See Section 9.28.

This would have the advantage of covering the other built-in triggers
not only suppress_redundant_updates_trigger.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples
  2020-06-12 09:09 Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples PG Doc comments form <noreply@postgresql.org>
  2020-06-16 10:36 ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Bruce Momjian <bruce@momjian.us>
  2020-06-16 14:08   ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Tom Lane <tgl@sss.pgh.pa.us>
  2020-06-16 16:41     ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Bruce Momjian <bruce@momjian.us>
  2020-06-16 17:39       ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Tom Lane <tgl@sss.pgh.pa.us>
@ 2020-06-16 17:49         ` Bruce Momjian <bruce@momjian.us>
  2020-06-16 18:02           ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 8+ messages in thread

From: Bruce Momjian @ 2020-06-16 17:49 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: petermpallesen@gmail.com; pgsql-docs@lists.postgresql.org

On Tue, Jun 16, 2020 at 01:39:45PM -0400, Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > I have developed the attached patch which is in a better direction.
> 
> I still wish you wouldn't jam this topic into an only-marginally-related
> sentence.  In the case at hand, the point that the existing text is
> making is that a no-op update will fire triggers.  Which is not
> something that suppress_redundant_updates_trigger will suppress,
> so again it seems confusing to mention that in the same breath.
> 
> I think that perhaps the right thing to do is add a new para to
> CREATE TRIGGER's "Notes" section, along the lines of
> 
>        There are a few built-in trigger functions that can be used
>        to solve common problems without having to write your own trigger
>        code.  See Section 9.28.
> 
> This would have the advantage of covering the other built-in triggers
> not only suppress_redundant_updates_trigger.

OK, I didn't think there was enough desire to put it its own paragraph,
but I like the idea of mentioning all of the trigger functions;  patch
attached.

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EnterpriseDB                             https://enterprisedb.com

  The usefulness of a cup is in its emptiness, Bruce Lee

Attachments:

trigger.diff (text/x-diff, 727B) download diff --git a/doc/src/sgml/ref/create_trigger.sgml b/doc/src/sgml/ref/create_trigger.sgml index 303881fcfb..289dd1d9da 100644 --- a/doc/src/sgml/ref/create_trigger.sgml +++ b/doc/src/sgml/ref/create_trigger.sgml @@ -457,6 +457,12 @@ UPDATE OF <replaceable>column_name1</replaceable> [, <replaceable>column_name2</ value did not change. </para> + <para> + There are a few built-in trigger functions that can be used to + solve common problems without having to write your own trigger code; + see <xref linkend="functions-trigger"/>. + </para> + <para> In a <literal>BEFORE</literal> trigger, the <literal>WHEN</literal> condition is evaluated just before the function is or would be executed, so using
^ permalink raw reply [nested|flat] 8+ messages in thread

* Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples
  2020-06-12 09:09 Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples PG Doc comments form <noreply@postgresql.org>
  2020-06-16 10:36 ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Bruce Momjian <bruce@momjian.us>
  2020-06-16 14:08   ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Tom Lane <tgl@sss.pgh.pa.us>
  2020-06-16 16:41     ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Bruce Momjian <bruce@momjian.us>
  2020-06-16 17:39       ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Tom Lane <tgl@sss.pgh.pa.us>
  2020-06-16 17:49         ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Bruce Momjian <bruce@momjian.us>
@ 2020-06-16 18:02           ` Tom Lane <tgl@sss.pgh.pa.us>
  2020-06-25 22:33             ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 8+ messages in thread

From: Tom Lane @ 2020-06-16 18:02 UTC (permalink / raw)
  To: Bruce Momjian <bruce@momjian.us>; +Cc: petermpallesen@gmail.com; pgsql-docs@lists.postgresql.org

Bruce Momjian <bruce@momjian.us> writes:
> OK, I didn't think there was enough desire to put it its own paragraph,
> but I like the idea of mentioning all of the trigger functions;  patch
> attached.

This one WFM.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples
  2020-06-12 09:09 Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples PG Doc comments form <noreply@postgresql.org>
  2020-06-16 10:36 ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Bruce Momjian <bruce@momjian.us>
  2020-06-16 14:08   ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Tom Lane <tgl@sss.pgh.pa.us>
  2020-06-16 16:41     ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Bruce Momjian <bruce@momjian.us>
  2020-06-16 17:39       ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Tom Lane <tgl@sss.pgh.pa.us>
  2020-06-16 17:49         ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Bruce Momjian <bruce@momjian.us>
  2020-06-16 18:02           ` Re: Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples Tom Lane <tgl@sss.pgh.pa.us>
@ 2020-06-25 22:33             ` Bruce Momjian <bruce@momjian.us>
  0 siblings, 0 replies; 8+ messages in thread

From: Bruce Momjian @ 2020-06-25 22:33 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: petermpallesen@gmail.com; pgsql-docs@lists.postgresql.org

On Tue, Jun 16, 2020 at 02:02:20PM -0400, Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > OK, I didn't think there was enough desire to put it its own paragraph,
> > but I like the idea of mentioning all of the trigger functions;  patch
> > attached.
> 
> This one WFM.

Patch applied to all supported versions.

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EnterpriseDB                             https://enterprisedb.com

  The usefulness of a cup is in its emptiness, Bruce Lee






^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2020-06-25 22:33 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-06-12 09:09 Not using suppress_redundant_updates_trigger in sql-createtrigger.html#examples PG Doc comments form <noreply@postgresql.org>
2020-06-16 10:36 ` Bruce Momjian <bruce@momjian.us>
2020-06-16 14:08   ` Tom Lane <tgl@sss.pgh.pa.us>
2020-06-16 16:41     ` Bruce Momjian <bruce@momjian.us>
2020-06-16 17:39       ` Tom Lane <tgl@sss.pgh.pa.us>
2020-06-16 17:49         ` Bruce Momjian <bruce@momjian.us>
2020-06-16 18:02           ` Tom Lane <tgl@sss.pgh.pa.us>
2020-06-25 22:33             ` Bruce Momjian <bruce@momjian.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox