| От | Tom Lane |
|---|---|
| Тема | Re: thw rewriter and default values, again |
| Дата | |
| Msg-id | 7714.1117293810@sss.pgh.pa.us обсуждение |
| Ответ на | thw rewriter and default values, again (Jaime Casanova <systemguards@gmail.com>) |
| Ответы |
Re: thw rewriter and default values, again
|
| Список | pgsql-hackers |
Jaime Casanova <systemguards@gmail.com> writes:
> create rule ins_rule as on insert to v_foo do instead
> insert into foo(col1, col2) values (new.col1, new.col2);
> insert into v_foo(col2) values (1);
> this give an error like:
> psql:f:/views.sql:13: ERROR: null value in column "col1" violates
> not-null constraint
That's not a bug, and "fixing" it isn't acceptable.
The correct solution to the problem you are looking at is
to attach default expressions to the view itself. Adding
alter table v_foo alter col1 set default nextval('public.foo_col1_seq');
to your example makes it work as you wish.
regards, tom lane
В списке pgsql-hackers по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера