thw rewriter and default values, again

Поиск
Список
Период
Сортировка
От Jaime Casanova
Тема thw rewriter and default values, again
Дата
Msg-id c2d9e70e05052806254304fb14@mail.gmail.com
обсуждение исходный текст
Ответы Re: thw rewriter and default values, again  (Greg Stark <gsstark@mit.edu>)
Re: thw rewriter and default values, again  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi, here we go again...

As you know there is a problem executing something like:

create table foo (
    col1 serial,
    col2 int
);

create view v_foo as select * from foo;

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

----

There is a workaround about this creating default values to the view.
Now, for updateable views we need this happen automatically, attached
there is a solution to this.
The only problem i have found until now is that
update v_foo set col1 = DEFAULT; execute nextval twice per every record.
so there will be a gasp between numbers, but AFAIK nextval has no guarantee
of returning sequential numbers.

Any comments on this?


--
regards,
Jaime Casanova
(DBA: DataBase Aniquilator ;)

Вложения

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: INOUT/OUT problems with IMMUTABLE
Следующее
От: Jochem van Dieten
Дата:
Сообщение: Re: overlaps() does not work as expected?