Re: Docs patch to note that rules only get run once per query.

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Sean Reifschneider <jafo(at)tummy(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, <pgsql-docs(at)postgresql(dot)org>
Subject: Re: Docs patch to note that rules only get run once per query.
Date: 2003-04-14 16:38:16
Message-ID: Pine.LNX.4.44.0304141449470.1919-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gmx(dot)net

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Sean Reifschneider 2003-04-14 17:53:25 Re: Docs patch to note that rules only get run once per query.
Previous Message Jan Wieck 2003-04-14 11:21:01 Re: Docs patch to note that rules only get run once per query.