Re: Clarification on RLS policy

Поиск
Список
Период
Сортировка
Искать
От
Dominique Devienne
Тема
Re: Clarification on RLS policy
Дата
Msg-id
CAFCRh-_fXGfKk6b26xaDD1fg5OhLy92bNofmeDfX2TFjkQLLXA@mail.gmail.com
Ответ на
Список
Дерево обсуждения
Clarification on RLS policy Vydehi Ganti <rayudugs@gmail.com>
Re: Clarification on RLS policy Laurenz Albe <laurenz.albe@cybertec.at>
Re: Clarification on RLS policy Dominique Devienne <ddevienne@gmail.com>
Re: Clarification on RLS policy Vydehi Ganti <rayudugs@gmail.com>
Re: Clarification on RLS policy Achilleas Mantzios - cloud <a.mantzios@cloud.gatewaynet.com>
Re: Clarification on RLS policy Adrian Klaver <adrian.klaver@aklaver.com>
Re: Clarification on RLS policy Dominique Devienne <ddevienne@gmail.com>
Re: Clarification on RLS policy Vydehi Ganti <rayudugs@gmail.com>
Re: Clarification on RLS policy Dominique Devienne <ddevienne@gmail.com>
Re: Clarification on RLS policy Vydehi Ganti <rayudugs@gmail.com>
Re: Clarification on RLS policy Dominique Devienne <ddevienne@gmail.com>
Re: Clarification on RLS policy Vydehi Ganti <rayudugs@gmail.com>
Re: Clarification on RLS policy Dominique Devienne <ddevienne@gmail.com>
Re: Clarification on RLS policy Achilleas Mantzios - cloud <a.mantzios@cloud.gatewaynet.com>
On Fri, Apr 25, 2025 at 2:43 PM Laurenz Albe  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 (Red Hat 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 по дате отправления
От: Laurenz Albe
Дата:
От: Vydehi Ganti
Дата:
FAQ