On 01/24/2014 07:16 PM, Dean Rasheed wrote: > My first thought is to add a boolean flag to RangeTblEntry (similar to > the "inh" flag) to say whether RLS expansion is requested for that > RTE. Then set it to false on each RTE as you add new RLS quals to it's > securityQuals.
That's what I was getting at with adding flags to RangeTblEntry, yes. Given the number of flags we're growing I wonder if they should be consolodated into a bitmask, but I'll leave that problem for later. I'll do this part first, since it seems you agree that a RangeTblEntry flag is the appropriate path. That'll make row-security checking work and make the patch testable. It won't deal with recursive rules, they'll still crash the backend. I'll deal with that as a further step. > In addition, when adding RLS quals to an RTE, I think they should be > fully and recursively expanded immediately, before setting the new > flag to false and moving on --- think recursively calling the rewriter > to expand view references in the new RLS qual, and > expand_security_qual() to expand any additional RLS quals in the > securityQuals list --- with loop detection there. I'm not pretending > that's going to be easy, but there are a couple of existing pieces of > code to borrow ideas from. Doing it this way should make it possible > to do the loop detection without any global structures. Ugh. I was really hoping to avoid *another* place where we do recursive expansion and infinite recursion checking, especially when the rewriter already does this job. Unfortunately, so long as the rewriter doesn't know about inheritance, it cannot fully solve this problem. A mutually recursive rule involving inheritance wouldn't get detected by rewriter based checking. The original RLS patch only detects direct recursion, btw, it looks like it won't catch mutual recursion. -- Craig Ringer http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-hackers mailing list (email@example.com) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers