I have a table which I'm trying to apply a policy on, the setup looks something like this:
create role anonymous nologin;
create schema api;
create schema private;
create table private.mytable(
id serial primary key,
description text default ''
);
create view api.mytable as select * from private.mytable;
insert into api.mytable (description) values ('row 1'), ('row 2');
grant usage on schema api to anonymous;
grant select on api.mytable to anonymous;
alter table private.mytable enable row level security;
create policy mytable_policy on private.mytable
for select
using (null);
When I set the role to anonymous
and select all records from mytable
:
set role anonymous;
select * from api.mytable;
I excpect no rows to be returned since my expression in the using
clause in the policy is null
but I get everything.
I tried different postgresql
versions (9.5, 9.6, 10.3) but they all have the same behaviour, am I doing something wrong here?