Re: WITH CHECK OPTION for auto-updatable views - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: WITH CHECK OPTION for auto-updatable views
Date
Msg-id CAFj8pRBm_49mp-gKE5vzMUbiUvgqJpxAovCOdw=objP1YZ9FxA@mail.gmail.com
Whole thread Raw
In response to Re: WITH CHECK OPTION for auto-updatable views  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: WITH CHECK OPTION for auto-updatable views
List pgsql-hackers
Hello

just some notes:

* autocomplete for INSERT, UPDATE, DELETE should to show updatable  views too

* can you explain better in doc differences between WITH CASCADED or
WITH LOCAL OPTION - assign some simple example to doc, please

* is possible to better identify (describe) failed constraints?

postgres=# create view v1 as select * from bubu where a > 0;
CREATE VIEW
postgres=# create view v2 as select * from v1 where a < 10 with check option;
CREATE VIEW
postgres=# insert into v1 values(-10);
INSERT 0 1
postgres=# insert into v2 values(-10);
ERROR:  new row violates WITH CHECK OPTION for view "v2" --- but this
constraint is related to v1
DETAIL:  Failing row contains (-10).

* I found a difference against MySQL - LOCAL option ignore all other constraints

postgres=# CREATE TABLE t1 (a INT);
CREATE TABLE
postgres=# CREATE VIEW v1 AS SELECT * FROM t1 WHERE a < 2 WITH CHECK OPTION;
CREATE VIEW
postgres=# CREATE VIEW v2 AS SELECT * FROM v1 WHERE a > 0 WITH LOCAL
CHECK OPTION;
CREATE VIEW
postgres=# INSERT INTO v2 VALUES (2);
ERROR:  new row violates WITH CHECK OPTION for view "v1" -- it will be
ok on MySQL
DETAIL:  Failing row contains (2).

Probably MySQL is wrong (due differet behave than in DB2) -- but who
know http://bugs.mysql.com/bug.php?id=6404

What is a correct behave?

Regards

Pavel



pgsql-hackers by date:

Previous
From: Jeff Davis
Date:
Subject: Re: fallocate / posix_fallocate for new WAL file creation (etc...)
Next
From: Greg Smith
Date:
Subject: Re: fallocate / posix_fallocate for new WAL file creation (etc...)