Re: API change advice: Passing plan invalidation info from the rewriter into the planner? - Mailing list pgsql-hackers
From | Robert Haas |
---|---|
Subject | Re: API change advice: Passing plan invalidation info from the rewriter into the planner? |
Date | |
Msg-id | CA+TgmoY9iAQMPkbLbJL-qebfyvfVWd8Xoaq_2a7_v_w4Rp5Qjg@mail.gmail.com Whole thread Raw |
In response to | Re: API change advice: Passing plan invalidation info from the rewriter into the planner? (Stephen Frost <sfrost@snowman.net>) |
Responses |
Re: RLS Design the rewriter into the planner?
|
List | pgsql-hackers |
On Tue, Jun 24, 2014 at 12:27 PM, Stephen Frost <sfrost@snowman.net> wrote: > I feel like we are getting to the point of simply talking past each > other and so I'll try anew, and I'll include my understanding of how the > different approaches would address the specific use-case you outlined > up-thread. Thanks, you're right, and this is a good write-up. > Single policy > ------------- > The current implementation approach only allows a single policy to be > included. > [...snip...] > For the case where a sales rep isn't also a partner, you could simplify > this to: > > WHERE > sales_rep_id = 16384 > > but I'm not sure that really buys you much? With the bitmap heap > scan, if one side of the OR ends up not returning anything then it > doesn't contribute to the blocks which have to be scanned. The index > might still need to be scanned, although I think you could avoid even > that with an EXISTS check to see if the user is a partner at all. > That's not to say that a bitmap scan is equivilant to an index scan, but > it's certainly likely to be far better than a sequential scan. True, but the wins could be much larger if one policy is WHERE sales_rep_id = (SELECT oid FROM pg_roles WHERE rolname = current_user) and the other policy is WHERE complexfn(). I'll also throw out a +1 for Dean's comments on this topic. > Multiple, Non-overlapping policies > ---------------------------------- > Preventing the overlap of policies ends up being very complicated if > many dimensions are allowed. For the simple case, perhaps only the > 'current role' dimension is useful. I expect that going down that > route would very quickly lead to requests for other dimensions (client > IP, etc) which is why I'm not a big fan of it, but if that's the > concensus then let's work out the syntax and update the patch and move > on. I think role is good enough. That's the primary identifier for all access-control related decisions, so it should be good enough here, too. I don't really understand your concerns about overlapping policies being complex. If you've got a couple of WHERE clauses, combining them with OR is not hard. Now, the query optimizer may have trouble with it, but on the whole I expect to win more than we lose, by entirely excluding some branches of an OR for users for whom entirely policies can be excluded. > Overall, while I'm interested in defining where this is going in a way > which allows us implement an initial RLS capability while avoiding > future upgrade issues, I am perfectly happy to say that the 9.5 RLS > implementation may not be exactly syntax-compatible with 9.6 or 10.0. Again, I think that's completely non-viable. Are you going to tell people they can't pg_upgrade, and they can't dump-and-reload either, without manual fiddling? There's no way that's going to be accepted. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
pgsql-hackers by date: