On this page
Audit a function before changing its grants
- 1Run this read-only query in your local Supabase database. Replace public.can_read_invoice(uuid) with the exact schema, name and argument types from the migration. A missing signature produces zero rows. A function with overloads needs a check for each relevant signature.
SQL select p.oid::regprocedure as signature, p.prosecdef as security_definer, pg_get_userbyid(p.proowner) as owner, r.rolname as role, has_schema_privilege(r.oid, p.pronamespace, 'USAGE') as schema_usage, has_function_privilege(r.oid, p.oid, 'EXECUTE') as can_execute from pg_proc as p cross join pg_roles as r where p.oid = to_regprocedure('public.can_read_invoice(uuid)') and r.rolname in ('anon', 'authenticated', 'service_role') order by r.rolname; - 2Search the migrations, application code and tests for references to the function name. Map each match to its actual runtime role. Include policies, triggers, jobs, wrappers and renamed or indirect RPC calls.
Terminal git grep -n -F 'can_read_invoice' - 3Compare that list with dependencies PostgreSQL recorded. The catalog includes stored dependencies such as policy expressions. Application calls, dynamic SQL and calls inside a string-defined function body require separate review.
SQL select pg_describe_object(d.classid, d.objid, d.objsubid) as dependent from pg_depend as d where d.refclassid = 'pg_proc'::regclass and d.refobjid = to_regprocedure('public.can_read_invoice(uuid)') order by dependent; - 4Decide which roles must execute it and whether it belongs in a Data API exposed schema. For a policy helper, a non-exposed schema can keep it off direct RPC while the policy still calls it. In a local migration, remove unintended direct grants and any unintended grant through PUBLIC or an inherited role. Re-query the effective privileges, then run the actual policy query or application flow with a known allowed test account before rolling out.
Related guides
Official docs behind this checklist
Browse all launch guides · Read resources · How to make and check your next change
FAQ for builders before launch
Why is EXECUTE still true after I revoke it from anon?
An effective grant can come from PUBLIC or a role that anon inherits. Inspect those grant paths for the exact overload before changing the migration.
Does authenticated EXECUTE limit a function to the caller's own rows?
EXECUTE controls who can invoke the function. SECURITY DEFINER runs with the owner's privileges. A function that handles tenant or user data still needs a check inside the function for the caller's allowed scope.