Replies: 1 comment
|
Short answer: yes for table-returning RPCs, no for scalar/JSON returns — and the function's own The longer version, because the layers matter: 1. PostgREST's 2. Scalar and JSON returns sidestep it. If the function returns a single row type or 3. The function's own LIMIT is authoritative at the SQL layer. If the function body contains an explicit 4. RLS interacts, SECURITY DEFINER doesn't. For an Practical pattern when you need guaranteed bounds on an RPC: create or replace function public.get_recent_items(p_limit int default 50)
returns setof public.items
language sql
security invoker
as $$
select * from public.items
order by created_at desc
limit greatest(1, least(p_limit, 500)); -- server-side clamp
$$;The server-side clamp means the client can never request unbounded results even if |
Uh oh!
There was an error while loading. Please reload this page.
Does row return limit apply to database functions ( rpc )?
All reactions