Luka Horvat
Luka Horvat

Reputation: 4402

Row level security does not work for table owner

I have a table, customer on which I did the following:

ALTER TABLE customer FORCE ROW LEVEL SECURITY;
CREATE POLICY customer_rls ON  customer USING (false);

However, doing SELECT * FROM customer still returns all the rows.

The current role is myrole

\dg myrole
           List of roles
 Role name | Attributes | Member of
-----------+------------+-----------
 my_role   |            | {}

As you can see it's not a superuser and it RLS isn't disabled on it.

What am I doing wrong?

Upvotes: 2

Views: 3864

Answers (1)

user330315
user330315

Reputation:

You forgot to enable row level security for the table.

ALTER TABLE customer enable ROW LEVEL SECURITY;

force only makes sure that RLS is applied if enabled, it does not enable RLS on the table.

Online example: https://rextester.com/TCLZ82421

Upvotes: 5

Related Questions