From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Ted Toth <txtoth@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: when is RLS policy applied
Date: Fri, 24 Jul 2020 14:15:03 -0700
Message-ID: <949e1dfd-0ffc-896b-3c5e-052a99fe74c9@aklaver.com> (raw)
In-Reply-To: <CAFPpqQFSfCjmx3TYjjDTECUgpeDkuPFQQO8Qe+s9TMdOjzV3gg@mail.gmail.com>
References: <CAFPpqQEs4qDXybQGaydQNYorHhzAW8KBK_7uSqDLNp2rm7a7zw@mail.gmail.com>
<575913.1595621731@sss.pgh.pa.us>
<CAFPpqQFQdms2i0Vu9bF3d8THtBzF_WyBMGrNdSO=BO-bQEyV9g@mail.gmail.com>
<CAFPpqQFSfCjmx3TYjjDTECUgpeDkuPFQQO8Qe+s9TMdOjzV3gg@mail.gmail.com>
On 7/24/20 2:12 PM, Ted Toth wrote:
> I've looked for information on leakproofness of operators but haven't
> found anything can you direct me to a source of this information?
See here:
https://www.postgresql.org/docs/12/catalog-pg-proc.html
"proleakproof bool The function has no side effects. No information
about the arguments is conveyed except via the return value. Any
function that might throw an error depending on the values of its
arguments is not leak-proof."
So as example:
select proname from pg_proc where proleakproof = 't';
select proname from pg_proc where proleakproof = 'f';
>
> On Fri, Jul 24, 2020 at 3:40 PM Ted Toth <txtoth@gmail.com
> <mailto:txtoth@gmail.com>> wrote:
>
>
> On Fri, Jul 24, 2020 at 3:15 PM Tom Lane <tgl@sss.pgh.pa.us
> <mailto:tgl@sss.pgh.pa.us>> wrote:
>
> Ted Toth <txtoth@gmail.com <mailto:txtoth@gmail.com>> writes:
> > I'm trying to understand when RLS select policy is applied so
> I created the
> > follow to test but I don't understand why the query filter
> order is
> > different for the 2 queries can anyone explain?
>
> The core reason why not is that the ~~ operator isn't considered
> leakproof. Plain text equality is leakproof, so it's safe to
> evaluate
> ahead of the RLS filter --- and we'd rather do so because the
> plpgsql
> function is assumed to be much more expensive than a built-in
> operator.
>
> (~~ isn't leakproof because it can throw errors that expose
> information
> about the pattern argument.)
>
> regards, tom lane
>
>
> Thanks for the explanation.
>
> Ted
>
--
Adrian Klaver
adrian.klaver@aklaver.com
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: adrian.klaver@aklaver.com, txtoth@gmail.com, tgl@sss.pgh.pa.us
Subject: Re: when is RLS policy applied
In-Reply-To: <949e1dfd-0ffc-896b-3c5e-052a99fe74c9@aklaver.com>
References: <CAFPpqQEs4qDXybQGaydQNYorHhzAW8KBK_7uSqDLNp2rm7a7zw@mail.gmail.com> <575913.1595621731@sss.pgh.pa.us> <CAFPpqQFQdms2i0Vu9bF3d8THtBzF_WyBMGrNdSO=BO-bQEyV9g@mail.gmail.com> <CAFPpqQFSfCjmx3TYjjDTECUgpeDkuPFQQO8Qe+s9TMdOjzV3gg@mail.gmail.com> <949e1dfd-0ffc-896b-3c5e-052a99fe74c9@aklaver.com>
* 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