Hi, While I was checking the behavior of RLS, I found that the policy for SELECT doesn't seem to be applied to RETURNING. Is this intentional? Please see the following example.
CREATE ROLE foo LOGIN NOSUPERUSER; CREATE TABLE hoge AS SELECT col FROM generate_series(1,10) col; ALTER TABLE hoge ENABLE ROW LEVEL SECURITY; GRANT SELECT, DELETE ON hoge TO foo; CREATE POLICY hoge_select_policy ON hoge FOR SELECT TO foo USING (col < 4); CREATE POLICY hoge_delete_policy ON hoge FOR DELETE TO foo USING (col < 8); \c - foo DELETE FROM hoge WHERE col = 6 RETURNING *; The policy "hoge_select_policy" should disallow the user "foo" to see the row with "col = 6". But the last DELETE RETURNING returns that row. One minor suggestion is: what about changing the message as follows? There are two more similar messages in policy.c, and they use the word "row-policy" instead of "policy". For the consistency, I think that the following also should use the word "row-policy". diff --git a/src/backend/commands/policy.c b/src/backend/commands/policy.c index 3627539..df45385 100644 --- a/src/backend/commands/policy.c +++ b/src/backend/commands/policy.c @@ -551,7 +551,7 @@ CreatePolicy(CreatePolicyStmt *stmt) if (HeapTupleIsValid(rsec_tuple)) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_OBJECT), - errmsg("policy \"%s\" for relation \"%s\" already exists", + errmsg("row-policy \"%s\" for relation \"%s\" already exists", Regards, -- Fujii Masao -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers