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

From: "Dmitry Koterov" <dmitry(at)koterov(dot)ru>
To: "Oleg Vasylenko" <pulp(at)mail(dot)ru>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to execute 'set session role' from plpgsql function?
Date: 2008-08-17 16:03:27
Message-ID: d7df81620808170903k1d841388w315cd86b1e941e00@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Just a suggestion:

EXECUTE 'SET SESSION ROLE wishedrole';

won't help?

2008/8/17 Oleg Vasylenko <pulp(at)mail(dot)ru>

> 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
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Roderick A. Anderson 2008-08-17 17:42:30 Re: [Q] DNS(bind) ER model
Previous Message Mark 2008-08-17 14:48:49 Re: [Q] DNS(bind) ER model