From: Karl Czajkowski <karlcz@isi.edu>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: RLS policy dump/restore failure due to elided type-casts
Date: Wed, 20 Apr 2016 18:37:53 -0700
Message-ID: <20160421013753.GC7976@moraine.isi.edu> (raw)
In-Reply-To: <CAKFQuwYM__6TZzn5Na05wN7icZX7_R10LsvtNQbBmFG+v4BRGg@mail.gmail.com>
References: <20160421001832.GB7976@moraine.isi.edu>
<5718206C.5070101@aklaver.com>
<CAKFQuwYM__6TZzn5Na05wN7icZX7_R10LsvtNQbBmFG+v4BRGg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-general>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: karlcz@isi.edu, david.g.johnston@gmail.com, adrian.klaver@aklaver.com
Subject: Re: RLS policy dump/restore failure due to elided type-casts
In-Reply-To: <20160421013753.GC7976@moraine.isi.edu>
References: <20160421001832.GB7976@moraine.isi.edu> <5718206C.5070101@aklaver.com> <CAKFQuwYM__6TZzn5Na05wN7icZX7_R10LsvtNQbBmFG+v4BRGg@mail.gmail.com> <20160421013753.GC7976@moraine.isi.edu>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox