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

From: Олег Василенко <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:02:57
Message-ID: E1KUiqP-000Ojd-00.pulp-mail-ru@f182.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 Oleg Vasylenko 2008-08-17 14:22:56 How to execute 'set session role' from plpgsql function?
Previous Message Dmitry Koterov 2008-08-17 12:49:45 Re: selecting data from subquery in same order