2

I am trying to grant permissions for a function to a user

postgres=# grant all privileges on function myfunction to a_user;

But I get:

ERROR:  syntax error at or near "to"
LINE 1: grant all privileges on function myfunction to a_user;

Any reason why?

My function starts like this:

CREATE OR REPLACE FUNCTION myfunction(
param_val1 varchar(255),
param_cal2 VARCHAR(255), 
param_val3 VARCHAR(255),
param_val4 current_category,
param_val5 current_type,
param_val6  VARCHAR(255),
param_val7 bigint,
param_val8 text )

2 Answers 2

7

You need to include the function signature, not just the name. In this case, if myfunction has zero parameters, it would be like this:

grant all privileges on function myfunction() to a_user;

EDIT

Seeing that the function does take parameters, the signature would be this:

myfunction(character varying, character varying, character varying, <rest of parameters>)
Sign up to request clarification or add additional context in comments.

2 Comments

what if it does have parameters? Do you include the name and type?
@Eli only parameter types are required, for instance, myfunction(integer, boolean), but you can also include the name. You can see the complete reference here
1

I tried this and it works:

GRANT ALL ON ALL FUNCTIONS IN SCHEMA schemaname TO a_user;

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.