Re: [BUGS] INSTEAD rule bug?

Поиск
Список
Период
Сортировка
От Dmitry Tkach
Тема Re: [BUGS] INSTEAD rule bug?
Дата
Msg-id 3F145205.9060403@openratings.com
обсуждение исходный текст
Ответ на Re: [BUGS] INSTEAD rule bug?  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [BUGS] INSTEAD rule bug?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
>
>
>Oh, I see what you're on about.  Sorry, a "DO INSTEAD NOTHING" only
>suppresses the original command, it does not suppress other rules.
>I think what you want is to make the insert_test rule conditional
>on x being not null.
>
>            regards, tom lane
>
>
Ok... What's wrong with this one then (three rules are conditional - if
x is null or y is null, the entry is rejected, if x is not null and y is
not null, it is inserted, the fourth rull is a dummy to prevent the
planner from complaining about not being able to insert into a view):



testdb=# create table test (x int not null, y int not null);
CREATE TABLE
testdb=# create view test_view as select * from test;
CREATE VIEW
testdb=# create rule reject_x as on insert to test_view where new.x is
null do instead
testdb=# create table test_reject (x int, y int, reason text);
CREATE TABLE
testdb=# create rule reject_x as on insert to test_view where x is null
do instead insert into test_reject values (new.*, 'NULL x');
CREATE RULE
testdb=# create rule reject_y as on insert to test_view where y is null
do instead insert into test_reject values (new.*, 'NULL y');
CREATE RULE
testdb=# create rule insert_test as on insert to test_view where x is
not null and y is not null do instead insert into test values (new.*);
CREATE RULE
testdb=# create rule insert_dummy as on insert to test_view do instead
nothing;
CREATE RULE
testdb=# insert into test values (null, null);
ERROR:  ExecInsert: Fail to add null value in not null attribute x

Now, why does this fail?
The only rule that attempts to insert anything into test has 'x is not
null and y is not null' as the qualifier.
What's wrong?

Thanks!

Dima



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

Предыдущее
От: "Vincent Hikida"
Дата:
Сообщение: Re: Fw: select null + 0 question
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [BUGS] INSTEAD rule bug?