Subject: Need help understanding has_function_privilege

From: Cosimo Simeone <[email-masked]>
Date: Wed, 19 Mar 2025 08:24:03 +0000

Hi!
I'd need help understanding what i am doing wrong...

Where am I:
=# \c
psql (15.8 (Homebrew), server 14.15 (Debian 14.15-1.pgdg120+1))
You are now connected to database "postgres" as user "postgres".

Init:
=# create role my_user;
=# create schema my_schema;
=# create function my_schema.my_func(p1 text) returns integer as $$select
1::integer;$$ language sql;

It works...
=#  select my_schema.my_func('x');
 my_func
---------
       1

Now, the controversial part:
=# SELECT has_function_privilege('my_user', 'my_schema.my_func(text)',
'execute');
 has_function_privilege
------------------------
 t

true?
Well... Ok, "whatever"... I revoke it:
=# revoke execute on function my_schema.my_func(text) from my_user;
REVOKE

But still:
=# select has_function_privilege('my_user', 'my_schema.my_func(text)',
'execute');
 has_function_privilege
------------------------
 t

What am I doing wrong? :-)

Thanks for help!

---

From: Joe Conway <[email-masked]>
Date: Thu, 20 Mar 2025 09:28:52 -0400

On 3/19/25 04:24, Cosimo Simeone wrote:
> =# create function my_schema.my_func(p1 text) returns integer as $ 
> $select 1::integer;$$ language sql;

See:

https://www.postgresql.org/docs/current/sql-createfunction.html#:~:text=execute%20privilege%20is%20granted%20to%20PUBLIC

-- 
Joe Conway
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com