Re: WITH CHECK OPTION for auto-updatable views

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: WITH CHECK OPTION for auto-updatable views
Date: 2013-07-05 07:22:21
Message-ID: CAFj8pRBm_49mp-gKE5vzMUbiUvgqJpxAovCOdw=objP1YZ9FxA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Smith 2013-07-05 07:23:20 Re: fallocate / posix_fallocate for new WAL file creation (etc...)
Previous Message Jeff Davis 2013-07-05 06:50:01 Re: fallocate / posix_fallocate for new WAL file creation (etc...)