Re: rules: evaluate inputs in advance

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Markus Schiltknecht <markus(at)bluegap(dot)ch>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: rules: evaluate inputs in advance
Date: 2006-05-12 13:57:05
Message-ID: 20060512135705.GF12955@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, May 12, 2006 at 03:51:18PM +0200, Markus Schiltknecht wrote:
> Hi,
>
> I was trying to create an updateable view. Suddenly I got foreign key
> violations when using nextval('myseq').
>
> As I understand, the rewriter does something similar to a simple text
> replacement (I guess copying the plan tree nodes?) so that nextval gets
> evaluated again for every rule that applies.
>
> Is this desirable? Are there applications which need every rule to
> reevaluate the input expressions? Or could that behaviour be changed so
> that the input values for the rules get evaluated only once?

It's a known problem. It's also one of the reasons why triggers are
recommended over rules. And it's not desirable behaviour.

There have been discussions about the problems with the rule system and
how it seems to fail on simple ideas. Yet no-one has come up with an
alternative that covers the current uses...

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-05-12 13:57:52 Re: Compiling on 8.1.3 on Openserver 5.05
Previous Message Markus Schiltknecht 2006-05-12 13:51:18 rules: evaluate inputs in advance