行级安全性不适用于 table 所有者

Row level security does not work for table owner

我有一个 table、customer,我在上面做了以下操作:

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

但是,SELECT * FROM customer 仍然 returns 所有行。

当前角色是myrole

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

如您所见,它不是超级用户,也没有禁用 RLS。

我做错了什么?

您忘记为 table 启用行级安全性。

ALTER TABLE customer enable ROW LEVEL SECURITY;

force 仅确保在启用时应用 RLS,它不会在 table.

上启用 RLS

在线示例:https://rextester.com/TCLZ82421