How to execute 'set session role' from plpgsql function?

From: Oleg Vasylenko <pulp(at)mail(dot)ru>
To: pgsql-general(at)postgresql(dot)org
Subject: How to execute 'set session role' from plpgsql function?
Date: 2008-08-17 14:22:56
Message-ID: E1KUj9k-000G2x-00.pulp-mail-ru@f63.mail.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mark 2008-08-17 14:48:49 Re: [Q] DNS(bind) ER model
Previous Message Олег Василенко 2008-08-17 14:02:57 How to execute 'set session role' from plpgsql function?