Re: DO INSTEAD and conditional rules - Mailing list pgsql-hackers

From Tom Lane
Subject Re: DO INSTEAD and conditional rules
Date
Msg-id 28763.1114497434@sss.pgh.pa.us
Whole thread Raw
In response to Re: DO INSTEAD and conditional rules  (Neil Conway <neilc@samurai.com>)
Responses Re: DO INSTEAD and conditional rules
Re: DO INSTEAD and conditional rules
List pgsql-hackers
Neil Conway <neilc@samurai.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


pgsql-hackers by date:

Previous
From: Neil Conway
Date:
Subject: Re: DO INSTEAD and conditional rules
Next
From: Neil Conway
Date:
Subject: Re: DO INSTEAD and conditional rules