how to call a function to define a police in supabase

hi guys , i have this function in my DB wich receives the auth.uid() like this : checkrolepedido(auth.uid())

the function is here , where idatual is the variable wich receives auth.uid():
begin
select "case" from (SELECT 
    CASE 
        WHEN EXISTS (SELECT 1 FROM estabelecimento WHERE estabelecimento.dono_loja = idatual)
             OR EXISTS (SELECT 1 FROM pedidos WHERE pedidos.uid_cliente = idatual)
        THEN True
        ELSE False
    END ) AS result;

  return "case";

end;


the problem is that , i cant use this function as my table police for select !,
my police is :
checkrolepedido(auth.uid())

Role authenticated.

when i try to run a select it shows :
PostgrestException(message: stack depth limit exceeded, code: 54001, details: Payload Too Large, hint: Increase the configuration parameter "max_stack_depth" (currently 2048kB), after ensuring the platform's stack depth limit is adequate.)
Was this page helpful?