On Tue, Aug 9, 2016 at 9:10 AM, Peter Eisentraut <
peter.eisentraut@2ndquadrant.com> wrote:
> On 8/8/16 5:46 PM, David G. Johnston wrote:
> > """
> > The SET clause causes the specified configuration parameter to be set t=
o
> > the specified value when the function is entered, and then restored to
> > its prior value when the function exits. SET FROM CURRENT saves the
> > session's current value of the parameter as the value to be applied whe=
n
> > the function is entered.
> > """
> >
> > https://www.postgresql.org/docs/current/static/sql-createfunction.html
> >
> > I expect the attached script to output "NOTICE: SP : thirdschema",
> > instead it outputs "NOTICE: SP: otherschema"
>
> I think the piece you are missing is that it saves the setting when the
> function is created, not when it is run.
>
With hindsight =E2=80=8BI understand this perfectly (and I swear I've broug=
ht this
up before and subsequently forgot)...
=E2=80=8BCan we change the second sentence in the above quote to something =
like:=E2=80=8B
=E2=80=8BSET FROM CURRENT is a convenience expression to capture the result=
of
current_setting('setting name') at the time of the function's creation. [if
more than just convenience an example of when this is useful would be nice]=
.
=E2=80=8B
The fact that there is no way obtain the useful "restored to its prior
value" behavior without specifying an explicit value is a short-coming, not
a bug. That said, changing search_paths in a function is likely asking for
trouble anyway so the lack probably isn't something worth fixing.
=E2=80=8BDavid J.=E2=80=8B
=E2=80=8B