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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
Cc: Олег Василенко <pulp(at)mail(dot)ru>, pgsql-general(at)postgresql(dot)org
Subject: Re: How to execute 'set session role' from plpgsql function?
Date: 2008-08-19 14:43:50
Message-ID: 20472.1219157030@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2008-08-19 14:49:09 Re: Re: can't get UPDATE ... RETURNING ... INTO ... to compile successfully
Previous Message Tom Lane 2008-08-19 14:38:57 Re: 8.3.3 win32 crashing