• Stephen Frost's avatar
    Include policies based on ACLs needed · 7d8db3e8
    Stephen Frost authored
    When considering which policies should be included, rather than look at
    individual bits of the query (eg: if a RETURNING clause exists, or if a
    WHERE clause exists which is referencing the table, or if it's a
    FOR SHARE/UPDATE query), consider any case where we've determined
    the user needs SELECT rights on the relation while doing an UPDATE or
    DELETE to be a case where we apply SELECT policies, and any case where
    we've deteremind that the user needs UPDATE rights on the relation while
    doing a SELECT to be a case where we apply UPDATE policies.
    
    This simplifies the logic and addresses concerns that a user could use
    UPDATE or DELETE with a WHERE clauses to determine if rows exist, or
    they could use SELECT .. FOR UPDATE to lock rows which they are not
    actually allowed to modify through UPDATE policies.
    
    Use list_append_unique() to avoid adding the same quals multiple times,
    as, on balance, the cost of checking when adding the quals will almost
    always be cheaper than keeping them and doing busywork for each tuple
    during execution.
    
    Back-patch to 9.5 where RLS was added.
    7d8db3e8
rowsecurity.out 102 KB