PostgreSQL – How to List All Functions with Arguments Allowed for a Role

functionspermissionspostgresql

I found how to list tables a role has permissions on. I found how to list all functions with arguments.

My question is: How to list all functions with arguments a role is allowed to execute?

Best Answer

You can use the has_function_privilege function for that:

SELECT p.pronamespace::regnamespace as schema,
       p.proname||'('||pg_get_function_arguments(p.oid)||')' as function
FROM pg_proc p 
WHERE has_function_privilege(p.oid, 'execute');
  and p.pronamespace <> 'pg_catalog'::regnamespace;