Re: Bug #510: conditional rules sometimes work more than once

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Bug #510: conditional rules sometimes work more than once
Дата
Msg-id 17399.1005075535@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Bug #510: conditional rules sometimes work more than once  (pgsql-bugs@postgresql.org)
Список pgsql-bugs
pgsql-bugs@postgresql.org writes:
> 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
called it.

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

В списке pgsql-bugs по дате отправления:

Предыдущее
От: pgsql-bugs@postgresql.org
Дата:
Сообщение: Bug #510: conditional rules sometimes work more than once
Следующее
От: Kovacs Zoltan
Дата:
Сообщение: Re: Bug #510: conditional rules sometimes work more than