Re: Bug #772: Rewriting on multi-record updates is

From: Rod Taylor <rbt(at)rbt(dot)ca>
To: Anto Prijosoesilo <antop64(at)yahoo(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Bug #772: Rewriting on multi-record updates is
Date: 2002-09-19 00:41:52
Message-ID: 1032396113.47165.12.camel@jester
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, 2002-09-18 at 17:08, Anto Prijosoesilo wrote:
> I was afraid that you're going to say that (use
> triggers) :-).
>
> I'm trying _not_ to use triggers because rules are
> more maintainable than triggers here in my
> environment. At least with rules someone who knows SQL
> would be able to maintain it with just a little extra
> training.
>
> The PostgreSQL 7.2 Reference Manual, in the section
> for CREATE RULE seems to imply that the rules are
> executed per row of the target table. I'm referring to
> paragraph 2 of the description.

Read the last paragraph of that section:

It is important to realize that a rule is really a query transformation
mechanism, or query macro. The entire query is processed to convert it
into a series of queries that include the rule actions. This occurs
before evaluation of the query starts. So, conditional rules are handled
by adding the rule condition to the WHERE clause of the action(s)
derived from the rule. The above description of a rule as an operation
that executes for each row is thus somewhat misleading. If you actually
want an operation that fires independently for each physical row, you
probably want to use a trigger not a rule. Rules are most useful for
situations that call for transforming entire queries independently of
the specific data being handled.

Not that the description is obvious, but it's there. Perhaps you know
of a better way (place) to state this?

--
Rod Taylor

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2002-09-19 00:44:36 Re: SET autocommit begins transaction?
Previous Message Sean Chittenden 2002-09-19 00:32:52 Re: SET autocommit begins transaction?