Re: DO INSTEAD and conditional rules

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, david(at)kineticode(dot)com, Jan Wieck <JanWieck(at)yahoo(dot)com>
Subject: Re: DO INSTEAD and conditional rules
Date: 2005-04-26 06:37:14
Message-ID: 28763.1114497434@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Neil Conway <neilc(at)samurai(dot)com> writes:
> Tom Lane wrote:
>> DO INSTEAD means that the *original* query will not execute; it does
>> not suppress actions produced by other rules.

> I think DO INSTEAD should control whether the original query is added to
> the set of query trees produced by the rule.

... which is what it does ...

> Since we apply rules in
> alphabetical order, I would expect the first rule's conditional to be
> checked; when it matches, we would apply the rule and replace the
> original query with the rule's action (since it is DO INSTEAD). We would
> then apply rules to the result of the first rule; since no more rules
> can be applied, the resulting query would be the result of the first rule.

Here I've got to differ. The alphabetical-order rule was introduced to
nail down the order of execution of operations that were going to happen
in any case, but would otherwise have happened in an unspecified order.
You are proposing to let it define what gets executed and what does not.
I don't think that's a great idea --- for one thing, it raises the ante
quite a bit as to whose idea of alphabetical order is definitive. But
more importantly, such a change will certainly break existing
applications, and you haven't offered a sufficiently compelling reason
why we should do that.

(I have been thinking more and more that we should consider a wholesale
redesign of the rule mechanism, because it sure seems not to answer the
needs/expectations of a lot of people out there. But I am not talking
about marginal questions like what INSTEAD means --- it seems to me that
there's some very fundamental disconnect between what the rewriter does
and what people want. I don't have any specific substitute proposal,
which is why I've not brought it up...)

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Neil Conway 2005-04-26 06:47:55 Re: DO INSTEAD and conditional rules
Previous Message Neil Conway 2005-04-26 06:10:39 Re: DO INSTEAD and conditional rules