> Using 7.1.3, I've got a problem with conditional rules. This is the
> same problem which occured also in 7.1.1, but it seems to be
> indeterministic (sometimes works, sometimes not).
> My definitions are attached in defs.pgsql. It requires t1.out and
> t2.out (contents of two tables written out with COPY statements). I
> tried to load defs.pgsql into a clean database and the conditional
> rule worked well. But in my production database the same UPDATE causes
> a strange thing: the RULE calls the function as many times as many
> rows the view contains.
Well, yes. The WHERE clause has to be tested at every row to see
whether it is true or not, doesn't it? Seems like you are expecting
the system to magically know the result of the function without having
Probably a more useful answer is this: there isn't any guarantee about
the order in which functions in a query's WHERE-clause will be executed.
I suspect you are assuming that
WHERE not szalllev_szamla_szamla_kapcs(new.szamla,new.tetelszam)
will be executed only after the constraints in your UPDATE'S WHERE
clause, but the planner just sees them all as a big heap of constraints,
and executes them in whatever order it thinks will be efficient.
If you are building a design in which such functions might have
side-effects, then you'd better reconsider your design.
regards, tom lane
In response to
pgsql-bugs by date
|Next:||From: Kovacs Zoltan||Date: 2001-11-06 21:35:17|
|Subject: Re: Bug #510: conditional rules sometimes work more than |
|Previous:||From: pgsql-bugs||Date: 2001-11-06 14:18:17|
|Subject: Bug #510: conditional rules sometimes work more than once|