Re: what are rules for?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Michael Shulman <shulman(at)mathcamp(dot)org>, Adam Rich <adam(dot)r(at)sbcglobal(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: what are rules for?
Date: 2008-06-24 16:08:53
Message-ID: 18734.1214323733@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Martijn van Oosterhout <kleptog(at)svana(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ryan Wells 2008-06-24 16:31:16 String Encoding Conversion Problem
Previous Message Martijn van Oosterhout 2008-06-24 15:39:06 Re: what are rules for?