Re: bug (?) with RULEs with WHERE

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: bug (?) with RULEs with WHERE
Дата
Msg-id 3033.1004205842@sss.pgh.pa.us
обсуждение исходный текст
Ответ на bug (?) with RULEs with WHERE  (Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>)
Ответы Re: bug (?) with RULEs with WHERE  (Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>)
Список pgsql-hackers
Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu> writes:
> foo=# CREATE TABLE a(foo integer);
> CREATE
> foo=# CREATE TABLE b(foo integer);
> CREATE
> foo=# CREATE VIEW c AS SELECT foo FROM a;
> CREATE
> foo=# CREATE RULE d AS ON INSERT TO c WHERE new.foo=5 DO INSTEAD SELECT foo FROM b;
> CREATE
> foo=# INSERT INTO c VALUES (5);
> ERROR:  Cannot insert into a view without an appropriate rule

You didn't provide a rule covering the new.foo<>5 case.

In practice, you *must* have an unconditional INSTEAD rule present for
any view operation you want to allow.  It can be DO INSTEAD NOTHING,
and then you can do all your useful work in conditional rules, but the
unconditional rule must be there.  Else the system thinks that perhaps
the insert into the view would really happen.
        regards, tom lane


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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: HISTORY file
Следующее
От: Tom Lane
Дата:
Сообщение: Re: consistent naming of components