Row security policies documentation question - Mailing list pgsql-general

From Alexander M. Sauer-Budge
Subject Row security policies documentation question
Date
Msg-id 2807A25C-E61C-42B7-BF6C-0F546C94AEBE@alum.mit.edu
Whole thread Raw
Responses Re: Row security policies documentation question
Re: Row security policies documentation question
List pgsql-general
Hello,

Section 5.7. on Row Security Policies (https://www.postgresql.org/docs/current/static/ddl-rowsecurity.html) for 9.5
says:

As a simple example, here is how to create a policy on the account relation to allow only members of the managers role
toaccess rows, and only rows of their accounts: 

CREATE TABLE accounts (manager text, company text, contact_email text);

ALTER TABLE accounts ENABLE ROW LEVEL SECURITY;

CREATE POLICY account_managers ON accounts TO managers
    USING (manager = current_user);

If no role is specified, or the special user name PUBLIC is used, then the policy applies to all users on the system.
Toallow all users to access their own row in a users table, a simple policy can be used: 

CREATE POLICY user_policy ON users
    USING (user = current_user);

---

I’m trying understand the example as it references both an `accounts` table and a `users` table which isn’t defined. Is
thisa mishmash of example fragments or should the CREATE POLICY statement reference the `accounts` table instead of
`users`?Specifically, what does `user` reference in the statement "CREATE POLICY user_policy ON users USING (user =
current_user);”?Is this a table column in a `users` table the example doesn’t define or does PostgreSQL keep track of
whatuser/role inserted a row and allow policies to use it? 

Thanks!
Alex



pgsql-general by date:

Previous
From: Joseph Kregloh
Date:
Subject: Re: Log Shipping
Next
From: "David G. Johnston"
Date:
Subject: Re: Row security policies documentation question