Re: The rule question before, request official documentation on the problem

From: Listmail <lists(at)peufeu(dot)com>
To: "Stuart Cooper" <stuart(dot)cooper(at)gmail(dot)com>, "Chris Travers" <chris(at)metatrontech(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: The rule question before, request official documentation on the problem
Date: 2007-04-11 11:22:18
Message-ID: op.tql9vggazcizji@apollo13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> Rules mess with queries. For data copying/archiving kinds of tasks,
> triggers are a better bet, like you suggested in your original post.
>
>> Let me put that a different way: rules can *only* be used where data
>> integrity is not at stake. My own thinking is that it might be time to
>> make an official recommendation that they are only safe for views.
>
> NEW and OLD mean different things in a PL/pgSQL context and a Rules
> context.
> In PL/pgSQL NEW and OLD are values, in Rules (which specifically mess
> with
> queries) they are expressions.
>
> The fact that the same words mean different things in different contexts
> is a bit unfortunate but not as messy as say using "NEWEXPR" in the
> Rules context would be.

Since we now have UPDATE/INSERT/DELETE RETURNING, one could imagine the
rules using these to access the actual rows and not the expressions...

But there is a perfectly valid argument against that :

- There already is a mechanism designed specifically for this purpose
(triggers).
- It works perfectly.
- Rules are supposed to rewrite queries to do stuff like views.

It should be mentioned in the docs, though : someone with an account on
the PG site should copypaste this mail exchange in the comments field...

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Nitin Verma 2007-04-11 11:40:14 ERROR: XLogFlush request 0/240169BC is not satisfied
Previous Message Michael Fuhr 2007-04-11 08:49:50 Re: Do I need serializable for this query?