Set Functions Definer Rights

From PostgreSQL wiki
Jump to navigationJump to search

Administrative Snippets

Set Functions to Run under Definer Rights

Works with PostgreSQL

Any version

Written in


Depends on


This will set the functions to run under the security privileges as the definer of the function rather than the caller.

update pg_proc 
   set prosecdef = true 
 where proname like '%your function name pattern%';

Setting definer rights allows for the function to have different privileges than the login user. Useful example of how to modify a function via the catalog.