Re: Docs patch to note that rules only get run once per query. - Mailing list pgsql-docs

From Peter Eisentraut
Subject Re: Docs patch to note that rules only get run once per query.
Date
Msg-id Pine.LNX.4.44.0304141449470.1919-100000@peter.localdomain
Whole thread Raw
In response to Re: Docs patch to note that rules only get run once per query.  (Sean Reifschneider <jafo@tummy.com>)
Responses Re: Docs patch to note that rules only get run once per query.
List pgsql-docs
Sean Reifschneider writes:

> <Note>
>  <Para>
>   Note that rules are only invoked once per query.  This may be a problem
>   in instances where the rule is updating table A based on table B's
>   contents.  If you do a multi-row delete on B, the rule may get run
>   only after the delete of the first row, not after all deletes finish.
>   In this case, you will have to use a trigger.
>  </Para>
> </Note>

This can't possibly be true.  Rules are never invoked "after" any deletion
of any row.  Take a close look at the examples of update rules in the
documentation.  Read how the references to NEW and OLD are resolved.
Play out the expansion of your example of paper.

The rule will expand your initial command to a big and ugly set of
commands.  But all those commands are applied like any normal command that
you could have entered by hand.  So if too few or too many rows are
affected, that's because of the conditions attached to the command.

--
Peter Eisentraut   peter_e@gmx.net


pgsql-docs by date:

Previous
From: Curt Sampson
Date:
Subject: Re: 6.8.5: Location of CURRENT_DATE unclear
Next
From: Sean Reifschneider
Date:
Subject: Re: Docs patch to note that rules only get run once per query.