Re: Clarification on RLS policy

Поиск
Список
Период
Сортировка
От Dominique Devienne
Тема Re: Clarification on RLS policy
Дата
Msg-id CAFCRh-_fXGfKk6b26xaDD1fg5OhLy92bNofmeDfX2TFjkQLLXA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Clarification on RLS policy  (Laurenz Albe <laurenz.albe@cybertec.at>)
Ответы Re: Clarification on RLS policy
Список pgsql-general
On Fri, Apr 25, 2025 at 2:43 PM Laurenz Albe <laurenz.albe@cybertec.at> wrote:
> On Fri, 2025-04-25 at 12:38 +0530, Vydehi Ganti wrote:
> > We are presently using Postgresql:PostgreSQL 15.12 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514
(RedHat 8.5.0-23), 64-bit 
> > 2.The function would return a character varying string which should be appended
> >   to the select as a filter.
>
> You cannot add whole WHERE conditions to a query dynamically.
> The only way to fix that is to solve the problem differently.
> Since you didn't tell us details, we cannot tell you how.

Laurenz is right. That's not how RLS works in PostgreSQL, unlike Oracle.
In PostgreSQL, you must use a boolean SQL expression, often by calling
a function.
You don't simply return some SQL text that Oracle then "splices" into
the SELECT.

E.g., if you use custom ROLEs as an implementation detail for your
security rules,
your policy can be as simple as calling the pg_has_role() built-in
function. FWIW. --DD

CREATE POLICY ... USING (pg_has_role('SomeRole', 'MEMBER'))



В списке pgsql-general по дате отправления: