Re: pgsql: WITH CHECK OPTION support for auto-updatable VIEWs

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: WITH CHECK OPTION support for auto-updatable VIEWs
Date: 2013-07-29 22:58:30
Message-ID: 20130729225830.GA31029@depesz.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Thu, Jul 18, 2013 at 09:24:02PM +0000, Stephen Frost wrote:
> WITH CHECK OPTION support for auto-updatable VIEWs
>
> For simple views which are automatically updatable, this patch allows
> the user to specify what level of checking should be done on records
> being inserted or updated. For 'LOCAL CHECK', new tuples are validated
> against the conditionals of the view they are being inserted into, while
> for 'CASCADED CHECK' the new tuples are validated against the
> conditionals for all views involved (from the top down).
>
> This option is part of the SQL specification.
>
> Dean Rasheed, reviewed by Pavel Stehule
>
> Branch
> ------
> master

What am I missing here:

create table some_data (id int4 primary key, payload text);
create view first as select * from some_data where 0 = id % 2 with local check option;
create view second as select * from first where 0 = id with local check option;

insert into second (id, payload) values (15, '15 is divisible by 3, but not by 2');
ERROR: new row violates WITH CHECK OPTION for view "first"
DETAIL: Failing row contains (15, 15 is divisible by 3, but not by 2).

If I read it correctly, insert to "second" with id = 15 should work,
because the where on "second" matches, and local check shouldn't be
checking on "first"?

Best regards,

depesz

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Stephen Frost 2013-07-29 23:43:53 Re: [COMMITTERS] pgsql: WITH CHECK OPTION support for auto-updatable VIEWs
Previous Message Greg Stark 2013-07-29 22:45:43 pgsql: Sync ECPG with WITH ORDINALITY changes

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2013-07-29 23:25:50 Re: [Pgbuildfarm-members] Bison 3.0 updates
Previous Message Christian Ullrich 2013-07-29 22:54:36 Re: Bison 3.0 updates