Rule action ordering

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Rule action ordering
Дата
Msg-id 17658.994444143@sss.pgh.pa.us
обсуждение исходный текст
Список pgsql-hackers
Jan Wieck <wieck@hub.org> writes:
>     Fire rule actions ON INSERT after original statement (if not INSTEAD).

It seems to me that this change of ordering should apply to
qual_products (ie, original statement with negation of a conditional
INSTEAD rule's condition) as well as to the unvarnished original
statement in the non-INSTEAD case.  Otherwise it's just about impossible
to give a coherent statement of what the behavior is.

However, when I tried making that change, a whole bunch of differences
popped up in the rules regression test.  They seemed to come from this
example:

create rule rtest_nothn_r1 as on insert to rtest_nothn1where new.a >= 10 and new.a < 20 do instead (select 1);

In the old regime, the SELECT got done before the INSERT, so psql throws
away the SELECT result and you see no output.  In the new regime, the
SELECT gets done last and you see its output.  What might be even more
confusing to newbies, you see SELECT output of zero rows when the rule's
WHERE condition fails (since the select is done anyway, but with a false
condition).

My feeling is that I should make the change and adjust the rule test's
expected output (probably by changing this rule to DO INSTEAD NOTHING).
Comments?
        regards, tom lane


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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: Problem with authentication in psql.
Следующее
От: Tom Lane
Дата:
Сообщение: Re: FE/BE protocol oddity