Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1at3bi-0006TR-NS for pgsql-general@arkaria.postgresql.org; Thu, 21 Apr 2016 01:40:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1at3bh-0002CT-Km for pgsql-general@arkaria.postgresql.org; Thu, 21 Apr 2016 01:40:37 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1at3ZP-00082d-LB for pgsql-general@postgresql.org; Thu, 21 Apr 2016 01:38:15 +0000 Received: from vapor.isi.edu ([128.9.64.64]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1at3ZM-0004OP-13 for pgsql-general@postgresql.org; Thu, 21 Apr 2016 01:38:13 +0000 Received: from moraine.isi.edu (moraine.isi.edu [128.9.64.90]) by vapor.isi.edu (8.13.8/8.13.8) with ESMTP id u3L1c2GS011310; Wed, 20 Apr 2016 18:38:02 -0700 (PDT) Date: Wed, 20 Apr 2016 18:37:53 -0700 From: Karl Czajkowski To: "David G. Johnston" Cc: Adrian Klaver , "pgsql-general@postgresql.org" Subject: Re: RLS policy dump/restore failure due to elided type-casts Message-ID: <20160421013753.GC7976@moraine.isi.edu> References: <20160421001832.GB7976@moraine.isi.edu> <5718206C.5070101@aklaver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-ISI-4-43-8-MailScanner: Found to be clean X-MailScanner-From: karlcz@isi.edu X-Pg-Spam-Score: -7.9 (-------) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org On Apr 20, David G. Johnston modulated: > The problem here is that: > > scalar = ANY (array) > is different than > scalar = ANY (subquery) > > The normalization in ?ruleutils? is munging things so that a query that > is written as "scalar = ANY(array) is transformed into one that is > "scalar = ANY(subquery)" > > The extra parentheses and the cast are needed to force a "scalar = ANY > (array)" where the basic expression looks like "scalar = ANY(subquery)" > Aha! Thanks for that. Now I realize there is a much simpler workaround: CREATE POLICY delete_stuff ON stuff FOR DELETE USING ('example attribute value' = ANY ( current_attributes() )); Somehow I fell into a pattern of writing scalar subqueries and I forgot to just write the function invocation directly as an expression! This policy seems to round-trip through pg_dump successfully. :-) By the way, we expose our session context parameter as an array result partly because we have other scenarios where we store row-level application ACLs in array-typed columns and may want to do array-to-array intersection tests in a policy expression. It was my intuition that gin indexing of those array-based ACL columns would then make these policy expressions pretty fast to evaluate. Karl -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general