Re: when is RLS policy applied - Mailing list pgsql-general

From Tom Lane
Subject Re: when is RLS policy applied
Date
Msg-id 575913.1595621731@sss.pgh.pa.us
Whole thread Raw
In response to when is RLS policy applied  (Ted Toth <txtoth@gmail.com>)
Responses Re: when is RLS policy applied
List pgsql-general
Ted Toth <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



pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: when is RLS policy applied
Next
From: Ted Toth
Date:
Subject: Re: when is RLS policy applied