Re: Question about RLS policy

From: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "'Garry Chen *EXTERN*'" <gc92(at)cornell(dot)edu>
Cc: "'pgsql-novice(at)postgresql(dot)org'" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Question about RLS policy
Date: 2017-06-09 06:57:43
Message-ID: A737B7A37273E048B164557ADEF4A58B53A5714D@ntex2010i.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Please keep the list on CC.

Garry Chen wrote:
> Thank you very much for your quick reply. I have a stored procedure or function
> (getpredicate2) as following and would like to use it inside using() so when I create
> policy as
> create policy plc_acct_nbr2 on distribution_fc for select to public using (acct_nbr in
> (select getpredicate2())) it return error as:
> ERROR: operator does not exist: character varying = acct_nbr_lst
> HINT: No operator matches the given name and argument type(s). You might need to add
> explicit type casts.
> ********** Error **********
>
> ERROR: operator does not exist: character varying = acct_nbr_lst
> SQL state: 42883
> Hint: No operator matches the given name and argument type(s). You might need to add
> explicit type casts.
>
>
> CREATE OR REPLACE FUNCTION public.getpredicate2(
> )
> RETURNS SETOF acct_nbr_lst
[...]

Your function returns "SETOF acct_nbr_lst", and "distribution_fc.acct_nbr" seems
to be of type character varying.

PostgreSQL does not know how to compare these two types, you'll have to tell it.

Either cast "acct_nbr" to "acct_nbr_lst", or have the function return
"SETOF character varying", or (more complicated) create an operator named "="
that can compare these two data types.

Yours,
Laurenz Albe

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Sharma, Sunidhi 2017-06-20 09:23:14 Question on installation of postgresql
Previous Message Albe Laurenz 2017-06-07 15:40:44 Re: Question about RLS policy