0

I created a login role in Postgres then I tried to give permissions to modify specified rows on a table using row level security. I've tried thousands times but it doesn't work. I have only one table.

enter image description here

3
  • 1
    How do you know it didn't work? Commented Jun 8, 2017 at 13:18
  • The screenshot shows that the creation of the rule worked just fine.So what exactly do you mean with "not working"? Commented Jun 8, 2017 at 13:33
  • What the values of id? Commented Jun 8, 2017 at 17:59

1 Answer 1

3

You didn't give enough information on what steps you took to come to your conclusion that it doesn't work, so I'll cover both cases:

  1. You created policy, but didn't enable RLS on table. From documentation:

Note that row-level security must be enabled on the table (using ALTER TABLE ... ENABLE ROW LEVEL SECURITY) in order for created policies to be applied.

  1. You are testing RLS using owner role, superuser role or role that inherits privileges from one of those. They bypass RLS by default. You can force RLS on table owner by ALTER TABLE [..] FORCE ROW LEVEL SECURITY, but you can't do that for superuser.
Sign up to request clarification or add additional context in comments.

4 Comments

I have enabled RLS . I created login role sergio and tried to give permissions to this role.Logged in as sergio and when i try to access my table i get an error message. No permissions . I posted the screenshot to be sure that I have not made a syntax mistake. any idea ?
Can you update your question with table definition from pgAdmin, including create query and permission grants?
hello friend ! I added image as another below. If u have a solution it will be great. Thanks
Also, any roles with the attributes 'superuser' or 'bypassrls' will never have RLS applied to them. In psql you can run \dg to see these attributes for all roles.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.