© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago•
4 replies
Tobi

RLS that a table can only be modified by a certain postgres function

Is it possible to write a RLS policy that restricts table update access except the update is coming from a certain function?

I tried this:

CREATE POLICY "Public counters can be updated by decrement_function." ON counters
FOR UPDATE
USING (
(CURRENT_SETTING('app.current_function') = 'hidden_functions.decrement_counter')
);

Which seems to block access from non authenticated update calls, but allows all functions to update it. But updates should only be allowed by "decrement_counter" function

Use case: I have a table with a counter and I only want to allo +1 and -1 operations if they are coming from a certain function which is part of an transaction.
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Create function for RLS that cannot be called by users
SupabaseSSupabase / help-and-questions
4y ago
Table with only 3 RLS is showing 40 RLS.
SupabaseSSupabase / help-and-questions
3y ago
Postgres RLS user
SupabaseSSupabase / help-and-questions
4y ago
Can't access a table using RLS.
SupabaseSSupabase / help-and-questions
4y ago