Rules with conditions over views don't work

Поиск
Список
Период
Сортировка
От pgsql-bugs@postgresql.org
Тема Rules with conditions over views don't work
Дата
Msg-id 200107061659.f66GxrP37669@hub.org
обсуждение исходный текст
Ответы Re: Rules with conditions over views don't work  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
José María Fernández González (jmfernandez@cnb.uam.es) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
Rules with conditions over views don't work

Long Description
    Since PostgreSQL 7.1 (or 7.0, I don't remember), if you define a view, and then a rule with a condition over the
view,the rule doesn't work when you try to do an operation from the type defined in the rule (it echoes an error
message).But, if you also define an empty rule of the same type on the same view with no condition, the rule starts
working.

    The real problem here is the query rewriting limit, which is reached when many rules of this type are involved in a
operation.

Sample Code
-- Sample table
create table a (
    b integer,
    c text
);

-- View over the table
create view va as
select * from a;

-- Rule to allow insertion
-- but it doesn't work by itself
create rule va_ins as
on insert to va
where new.b > 0
do instead
    insert into a values (new.*);

insert into va (b,c) values (3,'a');

ERROR:  Cannot insert into a view without an appropriate rule

-- With this trick it works again, but
-- you get nearer the query rewriting limit
create rule va_ins0 as
on insert to va
do instead nothing;

insert into va (b,c) values (3,'a');

INSERT 997472 1

No file was uploaded with this report

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

Предыдущее
От: pgsql-bugs@postgresql.org
Дата:
Сообщение: Query rewriting limit needs to be a little bigger or tunable
Следующее
От: pgsql-bugs@postgresql.org
Дата:
Сообщение: not ordered with multibyte language in V7.12