Re: what are rules for?
| От | Tom Lane |
|---|---|
| Тема | Re: what are rules for? |
| Дата | |
| Msg-id | 18734.1214323733@sss.pgh.pa.us обсуждение |
| Ответ на | Re: what are rules for? (Martijn van Oosterhout <kleptog@svana.org>) |
| Ответы |
Re: what are rules for?
|
| Список | pgsql-general |
Martijn van Oosterhout <kleptog@svana.org> writes:
> On Tue, Jun 24, 2008 at 10:28:00AM -0500, Michael Shulman wrote:
>> My question was, what else *can* you do with a rule that you *can't*
>> do with a trigger? Are rules only a way to speed up things that could
>> also be done with triggers?
> Well, views for one.
To expand on that: it's pretty hard to see how update or delete triggers
on a view would work. Insert is easy, because if left to its own
devices the system would in fact try to insert a tuple into the view
relation, and that action could fire a trigger which could redirect the
insertion someplace else. But updates and deletes require a
pre-existing target tuple, and there just aren't any of those in a view
relation. (Another way to say it is that update/delete require a CTID
column, which a view hasn't got.)
So view update/delete appear to require a transformational-rule kind
of approach instead of an actions-on-physical-tuples kind of approach.
If you've got a better idea we're all ears ...
regards, tom lane
В списке pgsql-general по дате отправления: