Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VdzLE-0007rb-Jr for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Nov 2013 09:24:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VdzLD-0000Ir-Ni for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Nov 2013 09:23:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VdzLC-0000Ii-Hh for pgsql-hackers@postgresql.org; Wed, 06 Nov 2013 09:23:58 +0000 Received: from outmail148154.authsmtp.co.uk ([62.13.148.154]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VdzL8-0003Dj-SO for pgsql-hackers@postgresql.org; Wed, 06 Nov 2013 09:23:57 +0000 Received: from mail-c235.authsmtp.com (mail-c235.authsmtp.com [62.13.128.235]) by punt6.authsmtp.com (8.14.2/8.14.2) with ESMTP id rA69NoL0063839; Wed, 6 Nov 2013 09:23:50 GMT Received: from ayaki.localdomain (124-148-67-24.dyn.iinet.net.au [124.148.67.24]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/) with ESMTP id rA69Ngkj021813 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 6 Nov 2013 09:23:45 GMT Message-ID: <527A0A9D.3090308@2ndquadrant.com> Date: Wed, 06 Nov 2013 17:23:41 +0800 From: Craig Ringer Organization: 2nd Quadrant User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: Dean Rasheed CC: Robert Haas , Tom Lane , Stephen Frost , Josh Berkus , Kohei KaiGai , "ktm@rice.edu" , Alexander Korotkov , Oleg Bartunov , Greg Smith , PgHacker Subject: Re: [v9.4] row level security References: <521F7DFB.8060602@agliodbs.com> <5220D832.7090104@agliodbs.com> <20130830192729.GO2706@tamriel.snowman.net> <16798.1377891794@sss.pgh.pa.us> <1398.1378305956@sss.pgh.pa.us> <1543.1378306249@sss.pgh.pa.us> <2620.1378308159@sss.pgh.pa.us> <52775604.9090306@2ndquadrant.com> <11101.1383575839@sss.pgh.pa.us> <52784DF9.9040205@2ndquadrant.com> <5279E3CA.7050400@2ndquadrant.com> In-Reply-To: X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Server-Quench: 24e909f7-46c5-11e3-b802-002590a15da7 X-AuthReport-Spam: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-AuthRoute: OCdxZQATClZeVg0b BQteCiNZVAwpPBRK HVkIKg5MJUcNSQVJ NksadwMSJgVCAnde RXkJW1VXQF14U2F2 YQ5YIwRfZlRPWw10 Vk9XQFZNFgBqBAMA SFxvVBAMIF4ceHxx bUdhEHVeW0B6O0R5 F0dUHDsBeGNmO2UC UUENdB4GeANIYx9F aFV2VCIMZDFWYTQC El17DBAYFhZyEh9g CjITfBROdA4RGSF0 Qx0cEDFnBkAOWj8y Mw1O X-Authentic-SMTP: 61633235383639.1023:706 X-AuthFastPath: 0 (Was 255) X-AuthSMTP-Origin: 124.148.67.24/2525 X-AuthVirus-Status: No virus detected - but ensure you scan with your own anti-virus system. X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 11/06/2013 05:02 PM, Dean Rasheed wrote: > The basic idea is to have rewriteTargetView() collect up any quals > from SB views in a new list on the target RTE, instead of adding them > to the main query's predicates (it needs to be a list of SB quals, in > case there are SB views on top of other SB views, in which case they > need to be kept separate from one another). Then at the end of the > rewriting process (after any views referenced in the SB quals have > been expanded), a new piece of code kicks in to process any RTEs with > SB quals, turning them into (possibly nested) subquery RTEs. That makes sense, though presumably you face the same problem that the existing RLS code does with references to system columns that don't normally exist in subqueries? Since this happens during query rewrite, what prevents the optimizer from pushing outer quals down into the subqueries? > The complication is that the query's resultRelation RTE mustn't be a > subquery. I think this is what Robert was alluding to earlier with his comments about join relations: ____ Robert Haas wrote: > I don't really see why. AIUI, the ModifyTable node just needs to get > the right TIDs. It's not like that has to be stacked directly on top > of a scan; indeed, in cases like UPDATE .. FROM and DELETE .. USING it > already isn't. Maybe there's some reason why the intervening level > can be a Join but not a SubqueryScan, but if so I'd expect we could > find some way of lifting that limitation without suffering too much > pain. (http://www.postgresql.org/message-id/CA+TgmoYr1PHw3X9vnVuWDcfXkzK2p_jhtWc0fV2Q58NEgcxyTA@mail.gmail.com) ____ Maybe we just need to make a subquery scan a valid target for an update, so those fixups aren't required anymore? > This is handled this in a similar way to the > trigger-updatable views code, producing 2 RTEs --- the resultRelation > RTE becomes a direct reference to the base relation, and a separate > subquery RTE acts as the source of rows to update. Some of the complexity of the current RLS code is caused by the need to do similar fixups to handle the case where the input relation isn't the same as the target relation, but is a subquery over it instead. > Anyway, feel free to do what you like with this. I wasn't planning on > submitting it to the next commitfest myself, because my non-PG > workload is too high, and I don't expect to get much time to hack on > postgresql during the next couple of months. Thanks for sending what you have. It's informative, and it shows that some of the same issues must be solved for writable security barrier views and for RLS. -- Craig Ringer http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers