I try to ALTER
a function with a new user and I get the error:
ERROR: must be owner of function ACases
********** Error **********
ERROR: must be owner of function ACases
SQL state: 42501
What permission do I have to give to a user so he can ALTER
that function?
The only way I found was to make the user the OWNER
of the function.
But if that is the case, only one user (owner) can ALTER
the function. So how would I change the OWNER
for all functions?
CREATE OR REPLACE FUNCTION public."ACases"(caseid integer)
RETURNS boolean AS
$BODY$
DECLARE
BEGIN
RETURN FALSE;
END;
$BODY$
LANGUAGE plpgsql;
ALTER FUNCTION public."ACases"(integer) OWNER TO postgres;
GRANT ALL PRIVILEGES ON FUNCTION public."ACases"(integer) TO user_name;
The manual on
ALTER FUNCTION
is clear on that:Bold emphasis mine.
You also need a couple of basic privileges to create functions. Per documentation:
The simple solution would be make changes to functions as superuser. (Default superuser is
postgres
, but any user can be made superuser.)If you really need to change ownership on all functions, this would do the trick:
Restricted to the
public
schema.For more details and explanation refer to this more complete answer on dba.SE.
Also closely related:
DROP FUNCTION without knowing the number/type of parameters?