"Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at> writes:
> EXECUTE 'SET SESSION ROLE "' || lower(regexp_replace(wishedrole, '"', '', 'g')) || '"';
> The "lower" and "regexp_replace" are there to prevent SQL injection.
quote_ident() would be a far better solution.
regards, tom lane