Re: Clarification on RLS policy - Mailing list pgsql-general

From Laurenz Albe
Subject Re: Clarification on RLS policy
Date
Msg-id 88804c921b425d37a3072b5698b558a763d80d63.camel@cybertec.at
Whole thread Raw
In response to Clarification on RLS policy  (Vydehi Ganti <rayudugs@gmail.com>)
Responses Re: Clarification on RLS policy
List pgsql-general
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
Hat8.5.0-23), 64-bit 
> I have a scenario where
> 1.I need to enforce RLS policy on a table for Select by calling a Function
> 2.The function would return a character varying string which should be appended
>   to the select as a filter.
> Ex: Select * from employee would be appended with where 1=1;
> 3.When we try to implement it says the below error.
>   ERROR: invalid input syntax for type boolean: "1=1" CONTEXT: PL/pgSQL function function name(name,name) while
castingreturn value to function's return type 
> 4.It works fine on Oracle. Can you please suggest how to fix this issue?

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.

Yours,
Laurenz Albe



pgsql-general by date:

Previous
From: Dominique Devienne
Date:
Subject: Re: Clarification on RLS policy
Next
From: Dominique Devienne
Date:
Subject: Re: Clarification on RLS policy