title: Postgres: updatable view (where in) with check option
body: <p>I try to create updatable views with <code>check option</code>.<br />
  When I have joins in the filtering criteria, I use a <code>where in</code> clause to simplify the queries.<br />
  However if I declare the view with both <code>check option</code> and <code>where in</code>, data validation doesn't seem reliable.
  I don't see this restriction in the doc: <a href="https://www.postgresql.org/docs/current/sql-createview.html" rel="nofollow noreferrer">https://www.postgresql.org/docs/current/sql-createview.html</a></p>
  <p>Is it a bug? Is there a workaround?</p>
  <pre><code>create table tableA (
      db_record_id serial NOT null PRIMARY KEY,
      &quot;name&quot; varchar(60) NOT null UNIQUE
  );
  
  create or replace view viewSimpleA
  as select * from tableA where name like 'a%'
  with check option;
  
  create or replace view viewA
  as select * from tableA
  where db_record_id in (
      select db_record_id from tableA
      where name like 'a%'
  ) with check option;
  
  insert into viewSimpleA(name) values('abc'); -- OK
  delete from tableA;
  
  insert into viewA(name) values('abc'); -- KO, SQL Error [44000]: ERROR: new row violates check option for view &quot;viewa&quot;
  delete from tableA;
  
  insert into viewSimpleA(name) values('abc');
  update viewSimpleA set name = 'fine'; -- OK: update is prevented by check option
  delete from tableA;
  
  insert table viewA(name) values('abc');
  update viewA set name = 'fine'; -- KO: update is executed, view is now empty
  delete from tableA;
  
  select version(); -- PostgreSQL 13.5 (Debian 13.5-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
  </code></pre>
  <p><strong>EDIT</strong>: I created a <a href="https://www.postgresql.org/message-id/CAJcNL1JZaFRZUM0r3SATJiuzvDArZtshHawMHXtqxh48BahmQQ%40mail.gmail.com" rel="nofollow noreferrer">bug report</a> here</p>