[HACKERS] CREATE OR REPLACE VIEW bug

Поиск
Список
Период
Сортировка
От Dean Rasheed
Тема [HACKERS] CREATE OR REPLACE VIEW bug
Дата
Msg-id CAEZATCUp=z=s4SzZjr14bfct_bdJNwMPi-gFi3Xc5k1ntbsAgQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: [HACKERS] CREATE OR REPLACE VIEW bug  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Список pgsql-hackers
It seems that there is a bug in CREATE OR REPLACE VIEW's handling of
WITH CHECK OPTION (noticed while thinking about the recent change to
pg_dump's handling of circular dependencies in views -- d8c05af). If
you use CREATE OR REPLACE VIEW on a view that isn't auto-updatable and
turn it into one that is, and at the same time attempt to add a WITH
CHECK OPTION (which is exactly what pg_dump will now do) it fails:

CREATE TABLE t1 (a int);
CREATE VIEW v1 AS SELECT null::int AS a;
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1 WHERE a > 0 WITH CHECK OPTION;

ERROR:  WITH CHECK OPTION is supported only on automatically updatable views
HINT:  Views that do not select from a single table or view are not
automatically updatable.


The problem is that before updating the view's query, DefineView()
calls DefineVirtualRelation() which attempts to add the new check
option to the existing view via the ALTER VIEW mechanism, and that
fails because the new check option isn't valid against the old view
query.

So if we're going to use the ALTER VIEW mechanism to update the view's
options, which is probably the most convenient way to do it,
DefineView()/DefineVirtualRelation() will need a little re-jigging to
do things in the required order.

I'll try to knock up a patch to do that.

Regards,
Dean



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

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: [HACKERS] PSQL commands: \quit_if, \quit_unless
Следующее
От: Dmitry Dolgov
Дата:
Сообщение: Re: [HACKERS] jsonb_delete with arrays