Re: [HACKERS] Updatable views

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [HACKERS] Updatable views
Дата
Msg-id 7908.1157037047@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [HACKERS] Updatable views  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-patches
Peter Eisentraut <peter_e@gmx.net> writes:
> Am Donnerstag, 31. August 2006 15:55 schrieb Tom Lane:
>> The proposed WITH CHECK OPTION implementation is unworkable for exactly
>> this reason --- it will give the wrong answers in the presence of
>> volatile functions such as nextval().

> I'm not sure why anyone would want to define a view condition containing a
> volatile function.  At least it wouldn't put a major dent into this feature
> if such views were decreed not updatable.

The problem is not with the view condition.  Consider

    CREATE TABLE data (id serial primary key, ...);

    CREATE VIEW only_new_data AS SELECT * FROM data WHERE id > 12345
        WITH CHECK OPTION;

    INSERT INTO only_new_data VALUES(nextval('data_id_seq'), ...);

The proposed implementation will execute nextval twice (bad), and will
apply the WITH CHECK OPTION test to the value that isn't the one stored
(much worse).  It doesn't help if the id is defaulted.

            regards, tom lane

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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: [HACKERS] Updatable views
Следующее
От: "Guillaume Smet"
Дата:
Сообщение: Re: [HACKERS] log_statement output for protocol