How to execute 'set session role' from plpgsql function? - Mailing list pgsql-general

From Oleg Vasylenko
Subject How to execute 'set session role' from plpgsql function?
Date
Msg-id E1KUj9k-000G2x-00.pulp-mail-ru@f63.mail.ru
Whole thread Raw
Responses Re: How to execute 'set session role' from plpgsql function?
List pgsql-general
Hi,everybody!

I wish to have a function with code above, but compiller generate
syntactic error at the line "SET SESSION ROLE wishedrole;".

How to pass the wishedrole value to the structure?

CREATE OR REPLACE FUNCTION f_switch_role(INOUT text,INOUT boolean) AS
 $BODY$
 DECLARE
   wishedrole ALIAS FOR $1;
   resetrole ALIAS FOR $2;
 BEGIN
   if resetrole=true then
            RESET ROLE;
            RETURN;
   end if;

>>>>ERROR OCURS AT THE NEXT LINE <<<<<<
   SET SESSION ROLE wishedrole;
   RETURN;

 END;
 $BODY$
 LANGUAGE 'plpgsql' VOLATILE

pgsql-general by date:

Previous
From: "Dmitry Koterov"
Date:
Subject: Re: selecting data from subquery in same order
Next
From: Mark
Date:
Subject: Re: [Q] DNS(bind) ER model