Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W81tZ-00085H-Ug for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Jan 2014 06:11:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W81tZ-0008Vz-9y for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Jan 2014 06:11:37 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W81tW-0008Vo-A2 for pgsql-hackers@postgresql.org; Tue, 28 Jan 2014 06:11:34 +0000 Received: from outmail149058.authsmtp.co.uk ([62.13.149.58]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W81tP-0004FP-4x for pgsql-hackers@postgresql.org; Tue, 28 Jan 2014 06:11:33 +0000 Received: from mail-c235.authsmtp.com (mail-c235.authsmtp.com [62.13.128.235]) by punt14.authsmtp.com (8.14.2/8.14.2) with ESMTP id s0S6BLQ6042486; Tue, 28 Jan 2014 06:11:21 GMT Received: from ayaki.localdomain (106-68-140-97.dyn.iinet.net.au [106.68.140.97]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/) with ESMTP id s0S6BDIH056698 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Tue, 28 Jan 2014 06:11:16 GMT Message-ID: <52E74A01.7070307@2ndquadrant.com> Date: Tue, 28 Jan 2014 14:11:13 +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: Gregory Smith , Greg Stark , Kohei KaiGai , PostgreSQL Hackers Subject: Re: Infinite recursion in row-security based on updatable s.b. views References: <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> <527C478D.4070901@2ndquadrant.com> <52ABCF6C.4010409@gmail.com> <52ABE150.6050201@2ndquadrant.com> <52D98436.2030508@gmail.com> <52DC82E2.5010801@2ndquadrant.com> <52DCBEF1.3010004@2ndquadrant.com> <52E1CC04.8040907@2ndquadrant.com> <52E1DAD8.30909@2ndquadrant.com> <52E22C8E.2020702@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: 00d94975-87e3-11e3-b802-002590a15da7 X-AuthReport-Spam: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-AuthRoute: OCdxZQATClZeVg0b BQteCiNZVAwpPBRK HVkIKg5MJUcNSQVJ NksacxtFag1bZ1hf HGQLWlBEUFt7WGJ/ agMfbAVbfExGQQRu UFZARU1QEQdtHh1P RR59VGsGDn1GfXh2 bE4sXHJbWEA0dUYp S0pdEmgbbWA1a30e URVbalFccAFXfh9H b1l/BXIINTQAKBg1 TUcAHxkaHhhlExEd YwcDLFQTXUtDBDM3 WgoZHDIpVUwDDz80 MFk9J1UBBkcNIw04 OEAsVRofNVcPEgFX A0hHBCI7b0JHTWxj EwJXQlV2 X-Authentic-SMTP: 61633235383639.1023:706 X-AuthFastPath: 0 (Was 255) X-AuthSMTP-Origin: 106.68.140.97/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 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 (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers